示例#1
0
        public string Generate()
        {
            string password = "";

            byte[] pwdbyte = Encoding.UTF8.GetBytes(domain + username);
            Array.Resize(ref pwdbyte, pwdbyte.Length + KGK.Length);
            Buffer.BlockCopy(KGK, 0, pwdbyte, pwdbyte.Length - KGK.Length, KGK.Length);

            byte[] saltbyte = Convert.FromBase64String(salt);

            using (var hmac = new HMACSHA512())
            {
                var df = new Pbkdf2(hmac, pwdbyte, saltbyte, iterations);
                byte[] hash = df.getBytes(64);

                password = PasswordRemixed(hash);
            }

            return password;
        }
示例#2
0
 private byte[] PBKDF2_SHA384(byte[] password, byte[] salt, int iterations, int outputBytes)
 {
     using (var hmac = new HMACSHA384())
     {
         var df = new Pbkdf2(hmac, password, salt, iterations);
         return df.getBytes(AppConst.AESKeySize + AppConst.AESBlockSize);
     }
 }
示例#3
0
 private byte[] PBKDF2_SHA256(string password, byte[] salt, int iterations, int outputBytes)
 {
     using (var hmac = new HMACSHA256())
     {
         var df = new Pbkdf2(hmac, Encoding.UTF8.GetBytes(password), salt, iterations);
         return df.getBytes(AppConst.AESKeySize);
     }
 }