mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
Added Dispose method
This commit is contained in:
parent
c257ef5a6e
commit
3a72117202
2 changed files with 9 additions and 4 deletions
|
|
@ -28,7 +28,7 @@ public AESMetadata()
|
||||||
public void DeleteMetadataFromBuffer(ref byte[] rawData)
|
public void DeleteMetadataFromBuffer(ref byte[] rawData)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[rawData.Length - this.OffsetToData];
|
byte[] buffer = new byte[rawData.Length - this.OffsetToData];
|
||||||
System.Buffer.BlockCopy(rawData, this.OffsetToData, buffer, 0, rawData.Length - this.OffsetToData);
|
Buffer.BlockCopy(rawData, this.OffsetToData, buffer, 0, rawData.Length - this.OffsetToData);
|
||||||
rawData = buffer;
|
rawData = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,6 +172,7 @@ public static string Encrypt(string plainText, string password,
|
||||||
}
|
}
|
||||||
|
|
||||||
symmetricKey.Dispose();
|
symmetricKey.Dispose();
|
||||||
|
derivedPassword.Dispose();
|
||||||
return Convert.ToBase64String(cipherTextBytes);
|
return Convert.ToBase64String(cipherTextBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,7 +240,8 @@ public static string Decrypt(string cipherText, string password, string salt = "
|
||||||
|
|
||||||
symmetricKey.Dispose();
|
symmetricKey.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
derivedPassword.Dispose();
|
||||||
return Encoding.UTF8.GetString(plainTextBytes, 0, byteCount);
|
return Encoding.UTF8.GetString(plainTextBytes, 0, byteCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,19 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Crypto_Notepad
|
namespace Crypto_Notepad
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores a string encrypted in memory to defend against memory dumps
|
/// Stores a string encrypted in memory to defend against memory dumps
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class EncryptedString
|
class EncryptedString: IDisposable
|
||||||
{
|
{
|
||||||
private TripleDES des = TripleDESCryptoServiceProvider.Create();
|
private readonly TripleDES des = TripleDES.Create();
|
||||||
private byte[] encryptedString = null;
|
private byte[] encryptedString = null;
|
||||||
|
|
||||||
|
public void Dispose() => des.Dispose();
|
||||||
|
|
||||||
public EncryptedString(string String)
|
public EncryptedString(string String)
|
||||||
{
|
{
|
||||||
des.GenerateIV();
|
des.GenerateIV();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue