Testing more garbage encryption
This commit is contained in:
@@ -58,27 +58,29 @@ public static class Encryption
|
||||
/// <returns>the decrypted bytes</returns>
|
||||
public static byte[] Decrypt(byte[] encryptedData, string udId)
|
||||
{
|
||||
using (var rj = Aes.Create())
|
||||
using (var rj = new RijndaelManaged())
|
||||
{
|
||||
rj.KeySize = EncryptionKeySize;
|
||||
rj.Mode = EncryptionMode;
|
||||
rj.BlockSize = EncryptionBlockSize;
|
||||
//rj.Padding = PaddingMode.None;
|
||||
byte[] rgbIv = Encoding.UTF8.GetBytes(udId.Replace("-", string.Empty).Substring(0, UdIdKeySize));
|
||||
byte[] keyBytes = new byte[KeyStringSize];
|
||||
byte[] encryptedValueBytes = new byte[encryptedData.Length - KeyStringSize];
|
||||
Array.Copy(encryptedData, encryptedData.Length - keyBytes.Length, keyBytes, 0, keyBytes.Length);
|
||||
Array.Copy(encryptedData, 0, encryptedValueBytes, 0, encryptedValueBytes.Length);
|
||||
ICryptoTransform transform = rj.CreateDecryptor(keyBytes, rgbIv);
|
||||
byte[] decryptedValueBytes = new byte[encryptedValueBytes.Length];
|
||||
using (MemoryStream ms = new MemoryStream(encryptedValueBytes))
|
||||
{
|
||||
using (CryptoStream cs = new CryptoStream(ms, transform, CryptoStreamMode.Read))
|
||||
{
|
||||
byte[] decryptedValueBytes = new byte[encryptedValueBytes.Length];
|
||||
cs.Read(decryptedValueBytes, 0, encryptedValueBytes.Length);
|
||||
cs.FlushFinalBlock();
|
||||
return decryptedValueBytes;
|
||||
cs.CopyTo(decryptedValueBytes);
|
||||
cs.Flush();
|
||||
ms.Flush();
|
||||
}
|
||||
}
|
||||
return decryptedValueBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user