I have a job to do where I need to save data from a list to text files.
These data are for the most part, password
, username
, idade
, nacionalidade
and numeroCC
. At work you are asked to encrypt username ;; password in a text file. The remaining data is stored in regular text files with fixed size.
Explaining better, I will have to create 6 files, 3 of them for pass and user encryption of each type of user of the program I am carrying out, with an organizer, several members of the organization, and adepts using the application to buy tickets have to be registered. The other files will have a fixed size to store the rest of the data.
How can I do the encryption part?
I already tried to do with the following code to encrypt.
private static byte[] key = new byte[10] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
private static byte[] iv = new byte[10] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
public static string encripta(string text)
{
SymmetricAlgorithm algorithm = DES.Create();
ICryptoTransform transform = algorithm.CreateEncryptor(key, iv);
byte[] inputbuffer = Encoding.UTF8.GetBytes(text);
byte[] outputBuffer = transform.TransformFinalBlock(inputbuffer, 0, inputbuffer.Length);
return Convert.ToBase64String(outputBuffer);
}