I am doing connection string encryption. we use our own encryption key with AES algorithm to do this. during the process, we need to convert string to byte array and then convert byte array back to string. I found the encoding play an important role on those conversions.
So I need to know the encoding C# is using to get above conversion right. Any idea how to get current encoding programmably?
If you’re looking to store an encrypted string in a config (or other plain text) file, you’re better off storing the encrypted bytes as a base64-encoded string.
Likewise:
You can use the first code block to obtain a base64-encoded string representation of your encrypted data, then save that string in the config file. Use the second block to convert that same string from the file back into an encrypted byte array.