Beispiel #1
0
        public void Test_GetHashVersion_ShouldReturnHashAndBcryptVersion_FromBcryptWithInvalidVersionAsString()
        {
            var password = "******";
            var result   = HashHelpers.GetHashVersion(password);

            result.Item1.Should().Be("$2$10$asdfassdasasfas");
            result.Item2.Should().Be(HashVersionEnum.Bcrypt);
        }
Beispiel #2
0
        public void Test_GetHashVersion_ShouldReturnHashAndIntermediateVersion_FromBcryptWithIntermediateVersion()
        {
            var password = "******";
            var result   = HashHelpers.GetHashVersion(password);

            result.Item1.Should().Be("$2$10$asdfassdasasfas");
            result.Item2.Should().Be(HashVersionEnum.Intermediate_SHA256_Bcrypt);
        }
Beispiel #3
0
        public void Test_GetHashVersion_ShouldReturnHashAndSHA256Version_FromValidSHA256WithoutVersion()
        {
            var password = "******";
            var result   = HashHelpers.GetHashVersion(password);

            result.Item1.Should().Be("ECD71870D1963316A97E3AC3408C9835AD8CF0F3C1BC703527C30265534F75AE");
            result.Item2.Should().Be(HashVersionEnum.SHA256);
        }
Beispiel #4
0
        public void Test_CreateHashWithVersion_ShouldReturnBcrypt_FromBcryptHashVersion()
        {
            var password = "******";
            var hashed   = HashHelpers.CreateHashWithVersion(password, HashVersionEnum.Bcrypt);
            var version  = HashHelpers.GetHashVersion(hashed);

            version.Item2.Should().Be(HashVersionEnum.Bcrypt);
        }
Beispiel #5
0
        public void Test_GetHashVersion_ShouldReturnEmptyStringAndUnknownVersion_FromEmptyString()
        {
            var password = "";
            var result   = HashHelpers.GetHashVersion(password);

            result.Item1.Should().Be("");
            result.Item2.Should().Be(HashVersionEnum.Unknown);
        }
Beispiel #6
0
        public void Test_GetHashVersion_ShouldReturnHashAndBcryptVersion_FromBcryptWithMoreThanOneColon()
        {
            // One extra colon
            var password = "******";
            var result   = HashHelpers.GetHashVersion(password);

            result.Item1.Should().Be("$2$10$asdf:asdfasdf");
            result.Item2.Should().Be(HashVersionEnum.Bcrypt);

            // 4 extra colons
            var password2 = "$2$10$asdf:asdf:asdf:asdf:asdf$3";
            var result2   = HashHelpers.GetHashVersion(password2);

            result2.Item1.Should().Be("$2$10$asdf:asdf:asdf:asdf:asdf");
            result2.Item2.Should().Be(HashVersionEnum.Bcrypt);
        }