Code cleanup

This commit is contained in:
Stone_Red
2026-06-12 15:18:02 +02:00
parent 9f2aae3ba8
commit c70fd501bc
11 changed files with 735 additions and 707 deletions
+15 -16
View File
@@ -3,25 +3,24 @@ using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Crypto.Parameters;
namespace RemSox.Cryptography
namespace RemSox.Cryptography;
public static class Pkcs5S2PasswordKeyDeriver
{
public static class Pkcs5S2PasswordKeyDeriver
private const int KeySize = 32; // 256-bit key
private const int Iterations = 150_000; // PBKDF2 cost factor
public static byte[] DeriveKey(string password, byte[] salt)
{
private const int KeySize = 32; // 256-bit key
private const int Iterations = 150_000; // PBKDF2 cost factor
Pkcs5S2ParametersGenerator generator = new Pkcs5S2ParametersGenerator(new Sha256Digest());
public static byte[] DeriveKey(string password, byte[] salt)
{
Pkcs5S2ParametersGenerator generator = new Pkcs5S2ParametersGenerator(new Sha256Digest());
generator.Init(
PbeParametersGenerator.Pkcs5PasswordToBytes(password.ToCharArray()),
salt,
Iterations
);
generator.Init(
PbeParametersGenerator.Pkcs5PasswordToBytes(password.ToCharArray()),
salt,
Iterations
);
return ((KeyParameter)generator.GenerateDerivedMacParameters(KeySize * 8))
.GetKey();
}
return ((KeyParameter)generator.GenerateDerivedMacParameters(KeySize * 8))
.GetKey();
}
}