, , id + . , .
id , AES DES. id ( 64-256 ), id ( .. !)
var encryptorForGenerateKey = Aes.Create();
encryptorForGenerateKey.BlockSize = 128;
encryptorForGenerateKey.KeySize = 128;
encryptorForGenerateKey.GenerateKey();
encryptorForGenerateKey.GenerateIV();
var key = encryptorForGenerateKey.Key;
var iv = encryptorForGenerateKey.IV;
var encryptor = Aes.Create();
var encryptorTransformer = encryptorForGenerateKey.CreateEncryptor(key, iv);
int id = 123;
var bytes = BitConverter.GetBytes(id);
var encrypted = encryptorTransformer.TransformFinalBlock(bytes, 0, bytes.Length);
var encryptedString = BitConverter.ToString(encrypted);
Console.WriteLine(encryptedString);
var decryptor = Aes.Create();
var decryptorTransformer = decryptor.CreateDecryptor(key, iv);
String[] arr = encryptedString.Split('-');
byte[] encrypted2 = new byte[arr.Length];
for (int i = 0; i < arr.Length; i++)
{
encrypted2[i] = Convert.ToByte(arr[i], 16);
}
var result = decryptorTransformer.TransformFinalBlock(encrypted2, 0, encrypted2.Length);
if (result.Length != sizeof(int))
{
throw new Exception();
}
var id2 = BitConverter.ToInt32(result, 0);
id= 123 id= 4E-CD-80-9E-7E-FB-A7-B9-74-B6-3A-37-57-9C-BD-A9. , Base64 -, . -: D2B4F51E6577967A2262E3AE51F3EC74, Base64: 0rT1HmV3lnoiYuOuUfPsdA==
, , DES . DES id :
F2-54-4B-CE-23-83-96-C2 // With -
F2544BCE238396C2 // Without -
8lRLziODlsI= // Base64
DES, AES DES BlockSize KeySize.