diff --git a/csharp/app/Backend/Utils/Crypto.cs b/csharp/app/Backend/Utils/Crypto.cs new file mode 100644 index 000000000..f2a236367 --- /dev/null +++ b/csharp/app/Backend/Utils/Crypto.cs @@ -0,0 +1,20 @@ +using System.Security.Cryptography; + +namespace Backend.Utils; + +public class Crypto +{ + public String ComputeHash(Byte[] bytesToHash, Byte[] salt) + { + var byteResult = new Rfc2898DeriveBytes(bytesToHash, salt, 10000); + return Convert.ToBase64String(byteResult.GetBytes(24)); + } + + public string GenerateSalt() + { + var bytes = new byte[128 / 8]; + var rng = new RNGCryptoServiceProvider(); + rng.GetBytes(bytes); + return Convert.ToBase64String(bytes); + } +} \ No newline at end of file