How to correctly and consistely get bytes from a string for AES encryption?
I am currently working on AES implementation in C#. The encryption method has two parameters: a string and a password. I am taking the supplied string and converting it to an array of bytes, so I can use it later for writing data to a stream with BinaryWriter . The problem is that when I use Convert.FromBase64String(string) I get FormatException: Invalid length. and when I use Encoding.UTF8.GetBytes(string) my decryption method throws and invalid PKCS7.Padding exception. I have been trying to solve this problem for the last couple of days. I have read near infinite questions in stackoverflow