Click here to Skip to main content
16,020,305 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, my Application loads a CSV file and transforms the Data in it. This Data is stored in a List<> I would like to be able to encrypt every row in this list with a public key and then save it to a new CSV file. After I saved the file with the encrypted data, I would like to encrypt this file again with a public key. The public key is a string like:
Quote:
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMDm/5kIEchm1R0oU46TuKEE7b5HQMgJ
1O8IdB3YqmMa9mTy178c0JkPfiigbDnGNfHlLX4DQ7KX2TZ+suK1Vj8CAwEAAQ==

and the private key for the decryption looks like this
Quote:
MIIBOwIBAAJBAMDm/5kIEchm1R0oU46TuKEE7b5HQMgJ1O8IdB3YqmMa9mTy178c
0JkPfiigbDnGNfHlLX4DQ7KX2TZ+suK1Vj8CAwEAAQJAdFRZ242UO8hXyMei7B6F
fwUb4l3R4VCcirIMZFtfFXgHC2lrrSB5IWWoNTCgiv7qf/V09uic5SPIMSp0EiU4
gQIhAN9RtawpAYsdMWwCY97pmEzfATYI84fNfQ0+tJdXipAfAiEA3SHFb1LReqoI
hsAH1zJppfmkUEyKozRljOKDdP4h9eECIArMZ62Aehug+L/RScUApKWq7uMPAb+i
Vxap3o+m4wNfAiEAj6JlBRdtW9jgKu7G6QAk4ZtTIJlnH/Vj1Ow46SA9XOECIQCF
sRjnfML4Pdp0oR1fh/YHJgCdxPBcGz8AoIwsfG1GgA==


I got this keys from this website:
[^]

A Bonus would be if I would be able to generate my own keys with a seperated very small application, but thats just a bonus, right now my main problem is that I would like to be able to encrypt and decrypt my csv file in a console app.

Thank you very much for your time and maybe help.

What I have tried:

I found several examples that do what I want but dont, like:

Public Key RSA Encryption in C# .NET[^]

Simple encrypting and decrypting data in C#[^]

and couple more on other sources I found with google, but nothing realy helped me.
Right now I'm using the 2nd link and I get an error when I try to decrypt my file.
Quote:
System.Security.Cryptography.CryptographicException: "Characters are invalid and can not be removed."

When I use the application from the first link, it pretty much does everything what I need but I dont really understand the source and I need it for a console application.
Posted
Updated 12-Dec-17 21:42pm
v2

1 solution

We aren't here to do your work for you: and if you have code that works but isn't for your environment, then it's important that you understand the code enough to transfer it to your new environment. We aren't here to explain someone else's code to you: we don't have time to write line by line explanations of how code works.

Transferring from a console to a windows app is complicated, but going the other way should be trivial. If you can't do that on your own, then quite honestly you are trying to run the marathon before you have learned to walk.

And if you get errors in using code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900