The method below is what I use to encrypt passwords. The method GetEntropy() simply returns random text.
The issue I am having, is that if I call the Crypt method with a string that contains a "%", for example Crypt("te%xt")
, and I then decrypt the encoding, it returns "tet". For some reason the %x is being read as something else. I tried to escape the %, for example Crypt("te/%xt")
, but that just returns "te/t".
static string Crypt(string text)
byte entropy = Encoding.ASCII.GetBytes(GetEntropy());
Encoding.Unicode.GetBytes(text), entropy, DataProtectionScope.CurrentUser));
Any guidance is much appreciated.