Example #1
0
        public void GivenIHaveHashedTheEncryptedArmorTokenUsingHMACSHA(int p0)
        {
            HashingMechanismFactory hashingMechanismFactory;

            switch (p0)
            {
            case 256:
                hashingMechanismFactory = new HMACSHA256HashingMechanismFactory(hashingKey, Convert.FromBase64String(encryptedArmorToken));
                break;

            case 512:
                hashingMechanismFactory = new HMACSHA512HashingMechanismFactory(hashingKey, Convert.FromBase64String(encryptedArmorToken));
                break;

            default:
                throw new NotImplementedException("Invalid Hashing Mode.");
            }

            using (var provider = new RNGCryptoServiceProvider()) provider.GetBytes(hashingKey);

            var armorTokenHasher = new ArmorTokenHasher(hashingMechanismFactory);

            armorTokenHasher.Execute();

            hashedArmorToken = armorTokenHasher.HashedArmorToken;
        }
Example #2
0
        public void GivenIHaveHashedTheValidArmorToken()
        {
            using (var provider = new RNGCryptoServiceProvider()) provider.GetBytes(hashingKey);

            var hashingMechanismFactory = new HMACSHA512HashingMechanismFactory(hashingKey, Convert.FromBase64String(encryptedArmorToken));
            var armorTokenHasher        = new ArmorTokenHasher(hashingMechanismFactory);

            armorTokenHasher.Execute();
            hashedArmorToken = armorTokenHasher.HashedArmorToken;
        }