mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
simplify the ECB and CBC
This commit is contained in:
parent
235ace8b1b
commit
ab8dda98b4
1 changed files with 3 additions and 21 deletions
|
@ -30,13 +30,7 @@ namespace LibHac
|
|||
aes.Key = key;
|
||||
aes.Mode = CipherMode.ECB;
|
||||
aes.Padding = PaddingMode.None;
|
||||
var dec = aes.CreateDecryptor();
|
||||
using (var ms = new MemoryStream(dest, destIndex, length))
|
||||
using (var cs = new CryptoStream(ms, dec, CryptoStreamMode.Write))
|
||||
{
|
||||
cs.Write(src, srcIndex, length);
|
||||
cs.FlushFinalBlock();
|
||||
}
|
||||
Array.Copy(aes.CreateDecryptor().TransformFinalBlock(src, srcIndex, src.Length), srcIndex, dest, destIndex, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,13 +46,7 @@ namespace LibHac
|
|||
aes.IV = iv;
|
||||
aes.Mode = CipherMode.CBC;
|
||||
aes.Padding = PaddingMode.None;
|
||||
var dec = aes.CreateDecryptor();
|
||||
using (var ms = new MemoryStream(dest, destIndex, length))
|
||||
using (var cs = new CryptoStream(ms, dec, CryptoStreamMode.Write))
|
||||
{
|
||||
cs.Write(src, srcIndex, length);
|
||||
cs.FlushFinalBlock();
|
||||
}
|
||||
Array.Copy(aes.CreateDecryptor().TransformFinalBlock(src, srcIndex, src.Length), srcIndex, dest, destIndex, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,13 +62,7 @@ namespace LibHac
|
|||
aes.IV = iv;
|
||||
aes.Mode = CipherMode.CBC;
|
||||
aes.Padding = PaddingMode.None;
|
||||
var dec = aes.CreateEncryptor();
|
||||
using (var ms = new MemoryStream(dest, destIndex, length))
|
||||
using (var cs = new CryptoStream(ms, dec, CryptoStreamMode.Write))
|
||||
{
|
||||
cs.Write(src, srcIndex, length);
|
||||
cs.FlushFinalBlock();
|
||||
}
|
||||
Array.Copy(aes.CreateEncryptor().TransformFinalBlock(src, srcIndex, src.Length), srcIndex, dest, destIndex, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue