From 7582f63a68739419271bbd9dc4f8ed8d79f88edf Mon Sep 17 00:00:00 2001 From: TheXamlGuy Date: Thu, 2 May 2024 23:07:48 +0100 Subject: [PATCH] Add code for opening vault --- Toolkit.Foundation/IKeyDeriver.cs | 5 ++++- Toolkit.Foundation/KeyDeriver.cs | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Toolkit.Foundation/IKeyDeriver.cs b/Toolkit.Foundation/IKeyDeriver.cs index 4a5a1b6..02fae2c 100644 --- a/Toolkit.Foundation/IKeyDeriver.cs +++ b/Toolkit.Foundation/IKeyDeriver.cs @@ -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); } diff --git a/Toolkit.Foundation/KeyDeriver.cs b/Toolkit.Foundation/KeyDeriver.cs index af3ea68..44bda0c 100644 --- a/Toolkit.Foundation/KeyDeriver.cs +++ b/Toolkit.Foundation/KeyDeriver.cs @@ -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); } }