Exemple #1
0
        public static string HashB64EncodedSalt(string password, string salt)
        {
            if (String.IsNullOrEmpty(password) || String.IsNullOrEmpty(salt))
            {
                throw new InvalidOperationException();
            }
            Blake2B blake2B = new Blake2B();

            blake2B.Salt = EncodingUtils.Base64Decode(salt);
            blake2B.Key  = StringUtils.GetBytes(password);
            byte[] data = blake2B.Final();
            return(EncodingUtils.Base64Encode(data));
        }
Exemple #2
0
        public static string Hash(string password, out string salt)
        {
            if (String.IsNullOrEmpty(password))
            {
                throw new InvalidOperationException();
            }
            Blake2B blake2B = new Blake2B();

            blake2B.Salt = StringUtils.GetRandomBytes(8 * 16);
            blake2B.Key  = StringUtils.GetBytes(password);
            salt         = EncodingUtils.Base64Encode(blake2B.Salt);
            byte[] data = blake2B.Final();
            return(EncodingUtils.Base64Encode(data));
        }