Add code for opening vault

This commit is contained in:
TheXamlGuy
2024-05-02 23:07:48 +01:00
parent 8d62f36931
commit 7582f63a68
2 changed files with 9 additions and 3 deletions
+4 -1
View File
@@ -1,5 +1,8 @@
namespace Toolkit.Foundation;
public interface IKeyDeriver
{
byte[] DeriveKey(string password, byte[] salt, int keySize = 32, int iterations = 10000);
byte[] DeriveKey(byte[] phrased,
byte[] salt,
int keySize = 32,
int iterations = 10000);
}
+5 -2
View File
@@ -5,9 +5,12 @@ namespace Toolkit.Foundation;
public class KeyDeriver :
IKeyDeriver
{
public byte[] DeriveKey(string password, byte[] salt, int keySize = 32, int iterations = 100000)
public byte[] DeriveKey(byte[] phrase,
byte[] salt,
int keySize = 32,
int iterations = 100000)
{
using Rfc2898DeriveBytes pbkdf2 = new(password, salt, iterations, HashAlgorithmName.SHA256);
using Rfc2898DeriveBytes pbkdf2 = new(phrase, salt, iterations, HashAlgorithmName.SHA256);
return pbkdf2.GetBytes(keySize);
}
}