public void ValidateSha256(string input, ShaProvider.Algorithm algorithm, string expectedHash) { ShaProvider sha = new ShaProvider(algorithm); string computedHash = sha.ComputeHash(input.GetBytes()).ToHex(); Assert.Equal(expectedHash, computedHash, true); }
public void ValidateSha256_Default() { byte[] input = "".GetBytes(); const string expectedHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; ShaProvider sha = new ShaProvider(); string computedHash = sha.ComputeHash(input).ToHex(); Assert.Equal(expectedHash, computedHash, true); }
public void GoodKeyAndIVTest(int keyLen, int ivLen) { AesProvider aes = new AesProvider(); ShaProvider sha = new ShaProvider(); byte[] plain = new byte[] { 0x96, 0x0D, 0x38, 0x4E, 0xE8, 0xE2, 0xE4, 0x7C, 0x32, 0x7D, 0xDB, 0x28, 0x50, 0x15, 0x23, 0x5E, 0xC1, 0xD8, 0x7A, 0x05, 0x19, 0x62, 0x63, 0x23, 0x1F, 0x27, 0x9C, 0x3B, 0xA9, 0x0E, 0x81, 0xB6 }; string plainHex = plain.ToHex(); byte[] encrypted = aes.Encrypt(plain); byte[] decrypted = aes.Decrypt(encrypted); Assert.Equal(plainHex, decrypted.ToHex()); }