Add code for opening vault
This commit is contained in:
@@ -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,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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user