Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Byte to char conversions
Message
From
18/03/2004 09:26:18
John Baird
Coatesville, Pennsylvania, United States
 
 
To
18/03/2004 08:10:20
John Baird
Coatesville, Pennsylvania, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00887452
Message ID:
00887478
Views:
10
>I hope I can articulate this so that you can understand the problem. I built to classes: Encrypt and Decrypt according to MSDN article. When I run the program to encrypt and decrypt strings with the test program, everything works fine. The process is:
>
>plaintext = "this is to be encrypted"
>ciphertext = encrypt(plaintext)
>returntext = decrypt(ciphertext)
>
>in this example plaintext and returntext are identical.
>
>I am trying to store the results of the encrypt to a registry string. ciphertext is a byte[] on the return so I am converting it to string for storage in the registry by using:
>
>mystring = Convert.ToBase64String(cipherText)
>
>in this example, ciphertext has a length of 48. I store mystring to the registry and retrieve it. This works fine. When I convert the plaintext from the registry back into a byte[] using:
>
>cipherText = Encoding.ASCII.GetBytes(mystring);
>
>the length is now 64 for ciphertext and the decrypt function fails returning an error message about PCKS7 padding is invalid.
>
>How can I store the ciphertext to the registry and reconvert it back to byte[] without physically changing the data? Hope this makes sense. Thanks.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform