diff --git a/Encrypter Tests/EncrypterTests.cs b/Encrypter Tests/EncrypterTests.cs
index 8355dd1..451cffd 100644
--- a/Encrypter Tests/EncrypterTests.cs
+++ b/Encrypter Tests/EncrypterTests.cs
@@ -19,10 +19,10 @@ namespace Encrypter_Tests
var message = "This is a test with umlauts äüö.";
var password = "test password";
- var encryptedData = await CryptoProcessor.EncryptString(message, password);
+ var encryptedData = await CryptoProcessor.Encrypt(message, password);
Assert.That(encryptedData.Length, Is.AtLeast(message.Length)); // Note: Encrypted data contains salt as well!
- var decryptedMessage = await CryptoProcessor.DecryptString(encryptedData, password);
+ var decryptedMessage = await CryptoProcessor.Decrypt(encryptedData, password);
Assert.That(decryptedMessage, Is.EqualTo(message));
}
@@ -32,8 +32,8 @@ namespace Encrypter_Tests
var message = string.Empty;
var password = "test password";
- var encryptedData = await CryptoProcessor.EncryptString(message, password);
- var decryptedMessage = await CryptoProcessor.DecryptString(encryptedData, password);
+ var encryptedData = await CryptoProcessor.Encrypt(message, password);
+ var decryptedMessage = await CryptoProcessor.Decrypt(encryptedData, password);
Assert.That(decryptedMessage, Is.EqualTo(message));
}
@@ -45,7 +45,7 @@ namespace Encrypter_Tests
try
{
- var encryptedData = await CryptoProcessor.EncryptString(message, password);
+ var encryptedData = await CryptoProcessor.Encrypt(message, password);
Assert.Fail("Should not be reached!");
}
catch(CryptographicException e)
@@ -62,7 +62,7 @@ namespace Encrypter_Tests
try
{
- var encryptedData = await CryptoProcessor.EncryptString(message, password);
+ var encryptedData = await CryptoProcessor.Encrypt(message, password);
Assert.Fail("Should not be reached!");
}
catch (CryptographicException e)
@@ -77,11 +77,11 @@ namespace Encrypter_Tests
var message = "This is a test with umlauts äüö.";
var password = "test password";
- var encryptedData = await CryptoProcessor.EncryptString(message, password);
+ var encryptedData = await CryptoProcessor.Encrypt(message, password);
try
{
- var decryptedMessage = await CryptoProcessor.DecryptString(encryptedData, password[..4]);
+ var decryptedMessage = await CryptoProcessor.Decrypt(encryptedData, password[..4]);
Assert.Fail("Should not be reached!");
}
catch (CryptographicException e)
@@ -96,8 +96,8 @@ namespace Encrypter_Tests
var message = Encoding.ASCII.GetString(Encoding.Convert(Encoding.UTF8, Encoding.ASCII, Encoding.UTF8.GetBytes("This is a test without umlauts.")));
var password = "test password";
- var encryptedData = await CryptoProcessor.EncryptString(message, password);
- var decryptedMessage = await CryptoProcessor.DecryptString(encryptedData, password);
+ var encryptedData = await CryptoProcessor.Encrypt(message, password);
+ var decryptedMessage = await CryptoProcessor.Decrypt(encryptedData, password);
Assert.That(decryptedMessage, Is.EqualTo(message));
}
@@ -108,11 +108,11 @@ namespace Encrypter_Tests
var password1 = "password!";
var password2 = "password.";
- var encryptedData = await CryptoProcessor.EncryptString(message, password1);
+ var encryptedData = await CryptoProcessor.Encrypt(message, password1);
try
{
- var decryptedMessage = await CryptoProcessor.DecryptString(encryptedData, password2);
+ var decryptedMessage = await CryptoProcessor.Decrypt(encryptedData, password2);
Assert.Fail("Should not be reached!");
}
catch (CryptographicException e)
@@ -140,16 +140,16 @@ namespace Encrypter_Tests
var previousIterations = 1_000;
var upgradedIterations = 1_000_000;
- var previousEncryptedData = await CryptoProcessor.EncryptString(message, password, previousIterations);
+ var previousEncryptedData = await CryptoProcessor.Encrypt(message, password, previousIterations);
var reEncryptedData = await CryptoProcessor.UpgradeIterations(previousEncryptedData, password, previousIterations, upgradedIterations);
Assert.That(previousEncryptedData, Is.Not.EqualTo(reEncryptedData));
- var decryptedMessage = await CryptoProcessor.DecryptString(reEncryptedData, password, upgradedIterations);
+ var decryptedMessage = await CryptoProcessor.Decrypt(reEncryptedData, password, upgradedIterations);
Assert.That(decryptedMessage, Is.EqualTo(message));
try
{
- var decryptedMessage2 = await CryptoProcessor.DecryptString(reEncryptedData, password, previousIterations);
+ var decryptedMessage2 = await CryptoProcessor.Decrypt(reEncryptedData, password, previousIterations);
Assert.Fail("Should not be reached!");
}
catch (CryptographicException e)
@@ -159,7 +159,7 @@ namespace Encrypter_Tests
try
{
- var decryptedMessage2 = await CryptoProcessor.DecryptString(previousEncryptedData, password, upgradedIterations);
+ var decryptedMessage2 = await CryptoProcessor.Decrypt(previousEncryptedData, password, upgradedIterations);
Assert.Fail("Should not be reached!");
}
catch (CryptographicException e)
@@ -176,16 +176,16 @@ namespace Encrypter_Tests
var newPassword = "test password!!!";
var iterations = 1_000;
- var previousEncryptedData = await CryptoProcessor.EncryptString(message, previousPassword, iterations);
+ var previousEncryptedData = await CryptoProcessor.Encrypt(message, previousPassword, iterations);
var reEncryptedData = await CryptoProcessor.ChangePassword(previousEncryptedData, previousPassword, newPassword, iterations);
Assert.That(previousEncryptedData, Is.Not.EqualTo(reEncryptedData));
- var decryptedMessage = await CryptoProcessor.DecryptString(reEncryptedData, newPassword, iterations);
+ var decryptedMessage = await CryptoProcessor.Decrypt(reEncryptedData, newPassword, iterations);
Assert.That(decryptedMessage, Is.EqualTo(message));
try
{
- var decryptedMessage2 = await CryptoProcessor.DecryptString(reEncryptedData, previousPassword, iterations);
+ var decryptedMessage2 = await CryptoProcessor.Decrypt(reEncryptedData, previousPassword, iterations);
Assert.Fail("Should not be reached!");
}
catch (CryptographicException e)
@@ -195,7 +195,7 @@ namespace Encrypter_Tests
try
{
- var decryptedMessage2 = await CryptoProcessor.DecryptString(previousEncryptedData, newPassword, iterations);
+ var decryptedMessage2 = await CryptoProcessor.Decrypt(previousEncryptedData, newPassword, iterations);
Assert.Fail("Should not be reached!");
}
catch (CryptographicException e)
@@ -216,8 +216,8 @@ namespace Encrypter_Tests
try
{
await File.WriteAllTextAsync(tempSourceFile, message);
- await CryptoProcessor.EncryptStream(File.OpenRead(tempSourceFile), File.OpenWrite(tempDestFile), password);
- await CryptoProcessor.DecryptStream(File.OpenRead(tempDestFile), File.OpenWrite(tempFinalFile), password);
+ await CryptoProcessor.Encrypt(File.OpenRead(tempSourceFile), File.OpenWrite(tempDestFile), password);
+ await CryptoProcessor.Decrypt(File.OpenRead(tempDestFile), File.OpenWrite(tempFinalFile), password);
Assert.That(File.Exists(tempDestFile), Is.True);
Assert.That(File.Exists(tempFinalFile), Is.True);
@@ -277,8 +277,8 @@ namespace Encrypter_Tests
var fileInfoSource = new FileInfo(tempSourceFile);
Assert.That(fileInfoSource.Length, Is.EqualTo(32_000_000_000));
- await CryptoProcessor.EncryptStream(File.OpenRead(tempSourceFile), File.OpenWrite(tempDestFile), password);
- await CryptoProcessor.DecryptStream(File.OpenRead(tempDestFile), File.OpenWrite(tempFinalFile), password);
+ await CryptoProcessor.Encrypt(File.OpenRead(tempSourceFile), File.OpenWrite(tempDestFile), password);
+ await CryptoProcessor.Decrypt(File.OpenRead(tempDestFile), File.OpenWrite(tempFinalFile), password);
Assert.That(File.Exists(tempDestFile), Is.True);
Assert.That(File.Exists(tempFinalFile), Is.True);
diff --git a/Encrypter/CryptoProcessor.cs b/Encrypter/CryptoProcessor.cs
index 52a5aa6..3ed74d5 100644
--- a/Encrypter/CryptoProcessor.cs
+++ b/Encrypter/CryptoProcessor.cs
@@ -25,7 +25,7 @@ namespace Encrypter
/// The password. Must consists of 6 chars or more.
/// The number of iterations to derive the key. Should not be adjusted. The default is secure for the current time.
/// The base64 encoded and encrypted string. The string is ASCII encoding.
- public static async Task EncryptString(string data, string password, int iterations = ITERATIONS_YEAR_2020)
+ public static async Task Encrypt(string data, string password, int iterations = ITERATIONS_YEAR_2020)
{
if (string.IsNullOrWhiteSpace(password) || password.Length < 6)
throw new CryptographicException("The password was empty or shorter than 6 characters.");
@@ -101,7 +101,7 @@ namespace Encrypter
/// The desired output stream. The encrypted data gets written to the current position.
/// The encryption password.
/// The desired number of iterations to create the key. Should not be adjusted. The default is secure for the current time.
- public static async Task EncryptStream(Stream inputStream, Stream outputStream, string password, int iterations = ITERATIONS_YEAR_2020)
+ public static async Task Encrypt(Stream inputStream, Stream outputStream, string password, int iterations = ITERATIONS_YEAR_2020)
{
if (string.IsNullOrWhiteSpace(password) || password.Length < 6)
throw new CryptographicException("The password was empty or shorter than 6 characters.");
@@ -171,7 +171,7 @@ namespace Encrypter
/// The password. Must consists of 6 chars or more.
/// The number of iterations to derive the key. Should not be adjusted. The default is secure for the current time.
/// The decrypted UTF8 encoded string.
- public static async Task DecryptString(string base64EncodedAndEncryptedData, string password, int iterations = ITERATIONS_YEAR_2020)
+ public static async Task Decrypt(string base64EncodedAndEncryptedData, string password, int iterations = ITERATIONS_YEAR_2020)
{
if (string.IsNullOrWhiteSpace(password) || password.Length < 6)
throw new CryptographicException("The password was empty or shorter than 6 characters.");
@@ -245,7 +245,7 @@ namespace Encrypter
/// The desired output stream. The decrypted data gets written to the current position.
/// The encryption password.
/// The desired number of iterations to create the key. Should not be adjusted. The default is secure for the current time.
- public static async Task DecryptStream(Stream inputStream, Stream outputStream, string password, int iterations = ITERATIONS_YEAR_2020)
+ public static async Task Decrypt(Stream inputStream, Stream outputStream, string password, int iterations = ITERATIONS_YEAR_2020)
{
if (string.IsNullOrWhiteSpace(password) || password.Length < 6)
throw new CryptographicException("The password was empty or shorter than 6 characters.");
@@ -313,10 +313,10 @@ namespace Encrypter
public static async Task UpgradeIterations(string encryptedDataBeforeUpgrade, string password, int previousIterations, int upgradedIterations)
{
// Decrypt the data with the previous settings:
- var decryptedData = await CryptoProcessor.DecryptString(encryptedDataBeforeUpgrade, password, previousIterations);
+ var decryptedData = await CryptoProcessor.Decrypt(encryptedDataBeforeUpgrade, password, previousIterations);
// Encrypt the data with the new settings:
- return await CryptoProcessor.EncryptString(decryptedData, password, upgradedIterations);
+ return await CryptoProcessor.Encrypt(decryptedData, password, upgradedIterations);
}
///
@@ -330,10 +330,10 @@ namespace Encrypter
public static async Task ChangePassword(string encryptedDataBeforeChange, string previousPassword, string newPassword, int iterations = ITERATIONS_YEAR_2020)
{
// Decrypt the data with the previous settings:
- var decryptedData = await CryptoProcessor.DecryptString(encryptedDataBeforeChange, previousPassword, iterations);
+ var decryptedData = await CryptoProcessor.Decrypt(encryptedDataBeforeChange, previousPassword, iterations);
// Encrypt the data with the new settings:
- return await CryptoProcessor.EncryptString(decryptedData, newPassword, iterations);
+ return await CryptoProcessor.Encrypt(decryptedData, newPassword, iterations);
}
}
}
diff --git a/Encrypter/Encrypter.xml b/Encrypter/Encrypter.xml
index a40cd06..efb560e 100644
--- a/Encrypter/Encrypter.xml
+++ b/Encrypter/Encrypter.xml
@@ -9,7 +9,7 @@
The number of iterations for the year 2020.
-
+
Encrypts a string by means of AES. The result gets base64 encoded.
Due to the necessary millions of SHA512 iterations, the methods runs at least several seconds in the year 2020 (approx. 5-7s).
@@ -22,7 +22,7 @@
The number of iterations to derive the key. Should not be adjusted. The default is secure for the current time.
The base64 encoded and encrypted string. The string is ASCII encoding.
-
+
Encrypts a given input stream and writes the encrypted data to the provided output stream. A buffer stream
gets used in front of the output stream. This method expects, that both streams are read-to-use e.g. the
@@ -37,7 +37,7 @@
The encryption password.
The desired number of iterations to create the key. Should not be adjusted. The default is secure for the current time.
-
+
Decrypts an base64 encoded and encrypted string. Due to the necessary millions of SHA512 iterations,
the methods runs at least several seconds in the year 2020 (approx. 5-7s).
@@ -50,7 +50,7 @@
The number of iterations to derive the key. Should not be adjusted. The default is secure for the current time.
The decrypted UTF8 encoded string.
-
+
Decrypts a given input stream and writes the decrypted data to the provided output stream. A buffer stream
gets used in front of the output stream. This method expects, that both streams are read-to-use e.g. the
diff --git a/Encrypter/Extensions.cs b/Encrypter/Extensions.cs
index ce47e47..bbd5830 100644
--- a/Encrypter/Extensions.cs
+++ b/Encrypter/Extensions.cs
@@ -21,7 +21,7 @@ namespace Encrypter
/// The base64 encoded and encrypted string. The string is ASCII encoding.
public static async Task Encrypt(this string data, string password, int iterations = CryptoProcessor.ITERATIONS_YEAR_2020)
{
- return await CryptoProcessor.EncryptString(data, password, iterations);
+ return await CryptoProcessor.Encrypt(data, password, iterations);
}
///
@@ -39,7 +39,7 @@ namespace Encrypter
/// The number of iterations to derive the key. Should not be adjusted. The default is secure for the current time.
public static async Task Encrypt(this Stream inputStream, Stream outputStream, string password, int iterations = CryptoProcessor.ITERATIONS_YEAR_2020)
{
- await CryptoProcessor.EncryptStream(inputStream, outputStream, password, iterations);
+ await CryptoProcessor.Encrypt(inputStream, outputStream, password, iterations);
}
///
@@ -55,7 +55,7 @@ namespace Encrypter
/// The decrypted UTF8 encoded string.
public static async Task Decrypt(this string data, string password, int iterations = CryptoProcessor.ITERATIONS_YEAR_2020)
{
- return await CryptoProcessor.DecryptString(data, password, iterations);
+ return await CryptoProcessor.Decrypt(data, password, iterations);
}
///
@@ -73,7 +73,7 @@ namespace Encrypter
/// The number of iterations to derive the key. Should not be adjusted. The default is secure for the current time.
public static async Task Decrypt(this Stream inputStream, Stream outputStream, string password, int iterations = CryptoProcessor.ITERATIONS_YEAR_2020)
{
- await CryptoProcessor.DecryptStream(inputStream, outputStream, password, iterations);
+ await CryptoProcessor.Decrypt(inputStream, outputStream, password, iterations);
}
}
}