mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
Added AESMetadata.WriteMetadata()
This commit is contained in:
parent
c155dc6d9c
commit
9841a0f16e
1 changed files with 10 additions and 5 deletions
|
|
@ -53,6 +53,15 @@ private bool ReadData(byte[] rawData, int offset, ref byte[] dataOut)
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void WriteMetadata(MemoryStream stream, byte[] IV, byte[] salt)
|
||||
{
|
||||
byte[] nullByte = { 0 };
|
||||
stream.Write(IV, 0, IV.Length);
|
||||
stream.Write(nullByte, 0, 1);
|
||||
stream.Write(salt, 0, salt.Length);
|
||||
stream.Write(nullByte, 0, 1);
|
||||
}
|
||||
|
||||
public bool GetMetadata(byte[] rawData)
|
||||
{
|
||||
int offset = 0;
|
||||
|
|
@ -114,11 +123,7 @@ public static string Encrypt(string plainText, string password,
|
|||
|
||||
using (MemoryStream memStream = new MemoryStream())
|
||||
{
|
||||
byte[] nullByte = { 0 };
|
||||
memStream.Write(symmetricKey.IV, 0, symmetricKey.IV.Length);
|
||||
memStream.Write(nullByte, 0, 1);
|
||||
memStream.Write(saltValueBytes, 0, saltValueBytes.Length);
|
||||
memStream.Write(nullByte, 0, 1);
|
||||
AESMetadata.WriteMetadata(memStream, symmetricKey.IV, saltValueBytes);
|
||||
|
||||
using (ICryptoTransform encryptor = symmetricKey.CreateEncryptor
|
||||
(keyBytes, symmetricKey.IV))
|
||||
|
|
|
|||
Loading…
Reference in a new issue