Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [next] -
## [Unreleased] -

### Changed

- Multiple functions, such as `generate_key` and `hash_password`, now return a `Result` due to the `rand` library upgrade.

### Removed

- Removed `EncryptWithKeyAsString`, `EncryptWithPasswordAsString`, `DecryptWithKeyAsString`, `DecryptWithPasswordAsString`,
`GenerateAPIKey`.

## [0.9.2] - 2025-01-20
- Online encryption feature

Expand Down
13 changes: 0 additions & 13 deletions wrappers/csharp/Examples.md

This file was deleted.

129 changes: 0 additions & 129 deletions wrappers/csharp/src/Managed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,6 @@ public static Argon2Parameters GetDefaultArgon2Parameters()
return Argon2Parameters.FromByteArray(rawParameters);
}

/// <summary>
/// Encrypts the data (which will be encoded into a UTF8 byte array) with the provided key.
/// </summary>
/// <param name="data">The data to encrypt.</param>
/// <param name="key">The key to use for encryption.</param>
/// <param name="aad">Additional authenticated data. (Optional).</param>
/// <param name="version">The cipher version to use. (Latest is recommended).</param>
/// <returns>Returns the encryption result as a base 64 encoded string.</returns>
[Obsolete("This method has been deprecated. Use EncryptWithKeyAsBase64String instead.")]
public static string EncryptWithKeyAsString(string data, byte[] key, byte[] aad = null, CipherTextVersion version = CIPHERTEXT_VERSION)
{
return EncryptWithKeyAsBase64String(data, key, aad, version);
}

/// <summary>
/// Encrypts the data (which will be encoded into a UTF8 byte array) with the provided key.
/// </summary>
Expand Down Expand Up @@ -315,20 +301,6 @@ public static byte[] DecryptAsymmetric(byte[] data, byte[] privateKey, byte[] aa
return result;
}

/// <summary>
/// Encrypts the data with the provided key.
/// </summary>
/// <param name="data">The data to encrypt.</param>
/// <param name="key">The key to use for encryption.</param>
/// <param name="aad">Additional authenticated data. (Optional).</param>
/// <param name="version">The cipher version to use. (Latest is recommended).</param>
/// <returns>Returns the encryption result as a base 64 encoded string.</returns>
[Obsolete("This method has been deprecated. Use EncryptWithKeyAsBase64String instead.")]
public static string EncryptWithKeyAsString(byte[] data, byte[] key, byte[] aad = null, CipherTextVersion version = CIPHERTEXT_VERSION)
{
return EncryptWithKeyAsBase64String(data, key, aad, version);
}

/// <summary>
/// Encrypts the data with the provided key.
/// </summary>
Expand Down Expand Up @@ -359,21 +331,6 @@ public static byte[] EncryptWithKey(byte[] data, byte[] key, byte[] aad = null,
return cipher;
}

/// <summary>
/// Encrypts the data with the provided password (which will be encoded into a UTF8 byte array and derived).
/// </summary>
/// <param name="data">The data to encrypt.</param>
/// <param name="password">The password to use for encryption.</param>
/// <param name="iterations">The number of iterations used to derive the password. 10 000 Recommended by NIST.</param>
/// <param name="aad">Additional authenticated data. (Optional).</param>
/// <param name="cipherTextVersion">The cipher version to use. (Latest is recommended).</param>
/// <returns>Returns the encryption result as a base 64 encoded string.</returns>
[Obsolete("This method has been deprecated. Use EncryptWithPasswordAsBase64String instead.")]
public static string EncryptWithPasswordAsString(byte[] data, string password, uint iterations = 10000, byte[] aad = null, CipherTextVersion cipherTextVersion = CIPHERTEXT_VERSION)
{
return EncryptWithPasswordAsBase64String(data, password, iterations, aad, cipherTextVersion);
}

/// <summary>
/// Encrypts the data with the provided password (which will be encoded into a UTF8 byte array and derived).
/// </summary>
Expand Down Expand Up @@ -743,21 +700,6 @@ public static byte[] EncryptAsymmetric(byte[] data, byte[] publicKey, byte[] aad
return result;
}

/// <summary>
/// Encrypts the data (which will be encoded into a UTF8 byte array) with the provided password (which will be encoded into a UTF8 byte array and derived).
/// </summary>
/// <param name="data">The data to encrypt.</param>
/// <param name="password">The password to use for encryption.</param>
/// <param name="aad">Additional authenticated data. (Optional).</param>
/// <param name="iterations">The number of iterations used to derive the password. 10 000 Recommended by NIST.</param>
/// <param name="cipherTextVersion">The cipher version to use. (Latest is recommended).</param>
/// <returns>Returns the encryption result as a base 64 encoded string.</returns>
[Obsolete("This method has been deprecated. Use EncryptWithPasswordAsBase64String instead.")]
public static string EncryptWithPasswordAsString(string data, string password, byte[] aad = null, uint iterations = 10000, CipherTextVersion cipherTextVersion = CIPHERTEXT_VERSION)
{
return EncryptWithPasswordAsBase64String(data, password, iterations, aad, cipherTextVersion);
}

/// <summary>
/// Encrypts the data (which will be encoded into a UTF8 byte array) with the provided password (which will be encoded into a UTF8 byte array and derived).
/// </summary>
Expand Down Expand Up @@ -890,19 +832,6 @@ public static byte[] EncryptWithPassword(string data, string password, uint iter
return cipher;
}

/// <summary>
/// Decrypts the base64 string with the provided key.
/// </summary>
/// <param name="b64data">The base 64 string to decrypt.</param>
/// <param name="key">The key to use for decryption.</param>
/// <param name="aad">Additional authenticated data. (Optional).</param>
/// <returns>Returns the decryption result as a UTF8 encoded string.</returns>
[Obsolete("This method has been deprecated. Use DecryptWithKeyAsUtf8String instead.")]
public static string DecryptWithKeyAsString(string b64data, byte[] key, byte[] aad = null)
{
return DecryptWithKeyAsUtf8String(b64data, key, aad);
}

/// <summary>
/// Decrypts the base64 string with the provided key.
/// </summary>
Expand Down Expand Up @@ -933,19 +862,6 @@ public static byte[] DecryptWithKey(string b64data, byte[] key, byte[] aad = nul
return result;
}

/// <summary>
/// Decrypts the data with the provided key.
/// </summary>
/// <param name="data">The data to decrypt.</param>
/// <param name="key">The key to use for decryption.</param>
/// <param name="aad">Additional authenticated data. (Optional).</param>
/// <returns>Returns the decryption result as a UTF8 encoded string.</returns>
[Obsolete("This method has been deprecated. Use DecryptWithKeyAsUtf8String instead.")]
public static string DecryptWithKeyAsString(byte[] data, byte[] key, byte[] aad = null)
{
return DecryptWithKeyAsUtf8String(data, key, aad);
}

/// <summary>
/// Decrypts the data with the provided key.
/// </summary>
Expand Down Expand Up @@ -976,20 +892,6 @@ public static byte[] DecryptWithKey(byte[] data, byte[] key, byte[] aad = null,
return result;
}

/// <summary>
/// Decrypts the data with the provided password (which will be encoded into a UTF8 byte array and derived).
/// </summary>
/// <param name="data">The data to decrypt.</param>
/// <param name="password">The password to use for decryption.</param>
/// <param name="iterations">The number of iterations used to derive the password.</param>
/// <param name="aad">Additional authenticated data. (Optional).</param>
/// <returns>Returns the decryption result as a UTF8 encoded string.</returns>
[Obsolete("This method has been deprecated. Use DecryptWithPasswordAsUtf8String instead.")]
public static string DecryptWithPasswordAsString(byte[] data, string password, uint iterations = 10000, byte[] aad = null)
{
return DecryptWithPasswordAsUtf8String(data, password, iterations, aad);
}

/// <summary>
/// Decrypts the data with the provided password (which will be encoded into a UTF8 byte array and derived).
/// </summary>
Expand Down Expand Up @@ -1040,20 +942,6 @@ public static string DecryptWithPasswordAsUtf8String(byte[] data, string passwor
return Utils.ByteArrayToUtf8String(result);
}

/// <summary>
/// Decrypts the base 64 data (which will be decoded to the original data) with the provided password (which will be encoded into a UTF8 byte array and derived).
/// </summary>
/// <param name="b64data">The data to decrypt.</param>
/// <param name="password">The password to use for decryption.</param>
/// <param name="iterations">The number of iterations used to derive the password.</param>
/// <param name="aad">Additional authenticated data. (Optional).</param>
/// <returns>Returns the decryption result as a UTF8 encoded string.</returns>
[Obsolete("This method has been deprecated. Use DecryptWithPasswordAsUtf8String instead.")]
public static string DecryptWithPasswordAsString(string b64data, string password, uint iterations = 10000, byte[] aad = null)
{
return DecryptWithPasswordAsUtf8String(b64data, password, iterations, aad);
}

/// <summary>
/// Join multiple shares to regenerate a shared secret.
/// </summary>
Expand Down Expand Up @@ -1301,23 +1189,6 @@ public static byte[] DecryptWithPassword(string b64data, string password, uint i
return result;
}

/// <summary>
/// Generates an API key.
/// </summary>
/// <returns>An API key formated as a Guid.</returns>
[Obsolete("This method has been deprecated. Use Managed.GenerateKey instead.")]
public static Guid GenerateAPIKey()
{
byte[] apiKey = GenerateKey(16);

if (apiKey == null)
{
return Guid.Empty;
}

return new Guid(apiKey);
}

/// <summary>
/// Decrypts the data with the provided key. No exceptions are thrown in case of failure.
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions wrappers/csharp/tests/unit-tests/TestManaged.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void DecryptWithKey()
}

[TestMethod]
public void DecryptWithKeyAsString()
public void DecryptWithKeyAsUtf8String()
{
string decryptResultString = Managed.DecryptWithKeyAsUtf8String(TestData.EncryptedData, TestData.BytesTestKey);
Assert.AreEqual(decryptResultString, TestData.Base64TestData);
Expand Down Expand Up @@ -90,7 +90,7 @@ public void DecryptWithPassword2_5()
}

[TestMethod]
public void DecryptWithPasswordAsString()
public void DecryptWithPasswordAsUtf8String()
{
string encryptedDataAsBase64 = "DQwCAAAAAgCoE9Y3m06QaPSAiL2qegthcm0+zZWt4fXbdqcefkzD6y8pnWsMzLkx/32t";
string decryptResultString = Managed.DecryptWithPasswordAsUtf8String(encryptedDataAsBase64, TestData.TestPassword);
Expand Down Expand Up @@ -153,7 +153,7 @@ public void EncryptBase64WithPasswordAsString()
}

[TestMethod]
public void EncryptWithKeyAsStringDecryptWithKeyAsString()
public void EncryptDecryptWithKeyAsBase64String()
{
byte[] encodedData = Utils.StringToUtf8ByteArray(TestData.StringTestData);
byte[] encodedPassword = Utils.StringToUtf8ByteArray(TestData.TestPassword);
Expand All @@ -174,7 +174,7 @@ public void EncryptWithKeyDecryptWithKey()
}

[TestMethod]
public void EncryptWithPasswordAsString()
public void EncryptWithPasswordAsBase64String()
{
byte[] encodedDataAsUtf8ByteArray = Utils.StringToUtf8ByteArray(TestData.StringTestData);
string encryptResultAsBase64String = Managed.EncryptWithPasswordAsBase64String(encodedDataAsUtf8ByteArray, TestData.TestPassword);
Expand All @@ -183,7 +183,7 @@ public void EncryptWithPasswordAsString()
}

[TestMethod]
public void EncryptWithPasswordAsStringAndDecryptWithPasswordAsString()
public void EncryptDecryptWithPasswordAsBase64String()
{
byte[] base64EncodedToUtf8ByteArray = Utils.StringToUtf8ByteArray(TestData.Base64TestData);
string password = "pwd";
Expand Down