public void KnownValueProducesKnownHash()
        {
            string password = "******";
            var    hash     = "$pbkdf2-sha512$10001$2ZuTslYKAYDQGiPkfA.B8A$ChsEXEjanEToQcPJiuVaKk0Ls3n0YK7gnxsu59rxWOawl/iKgo0XSWyaAfhFV0.Yu3QqfehB4dc7yGGsIW.ARQ";

            var equal = GenerateComparableHash.VerifyNonstandardHash(password, hash);

            Assert.IsTrue(equal);
        }
示例#2
0
        public static bool VerifyNonstandardHash(string password, string hash)
        {
            var components = hash.Split('$');
            var algo       = components[1];
            var iterations = components[2];
            var rawsalt    = components[3];
            var rawhash    = components[4];

            String salt = GenerateComparableHash.StandardiseBase64(rawsalt);

            string regenerated    = GenerateComparableHash.Generate64BitHash(password, salt, int.Parse(iterations));
            string destandardised = GenerateComparableHash.DestandardiseBase64(regenerated);

            return(rawhash == destandardised);
        }