Of course, there's an equivalent method to decrypt the encrypted string with the same password. The following class is one I wrote a while ago to perform exactly the kind of thing you're after, a simple single method call to allow some string-based plaintext to be encrypted with a string-based password, with the resulting encrypted string also being represented as a string. but this is precisely the kind of detail that can be somewhat abstracted away within your "wrapper" class. The RijndaelManaged class does indeed normally require you to "muck about" with byte arrays, salts, keys, initialization vectors etc. Rijndael is the algorithmic name of the current Advanced Encryption Standard, so you're certainly using an algorithm that could be considered "best practice". You can, however, "roll your own" wrapper class around something like the built-in RijndaelManaged cryptography class. See the end of the post for a list of specific improvements.Īs other people have said, Cryptography is not simple so it's best to avoid "rolling your own" encryption algorithm. UPDATE 23/Dec/2015: Since this answer seems to be getting a lot of upvotes, I've updated it to fix silly bugs and to generally improve the code based upon comments and feedback.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |