public static byte[] Encrypt( this ICipher cipher, ushort data) { if (cipher == null) { throw new ArgumentNullException(nameof(cipher)); } return(cipher.Encrypt(ToByteArray.Convert(data))); }
/// <summary> /// Hashes the specified <paramref name="data"/>. /// </summary> /// <param name="hasher">The hasher.</param> /// <param name="data">The data.</param> /// <returns>The hash value as a byte array.</returns> public static byte[] Hash( this IHasher hasher, Guid data) { if (hasher == null) { throw new ArgumentNullException(nameof(hasher)); } return(hasher.Hash(ToByteArray.Convert(data))); }
/// <summary> /// Verifies that the passed <paramref name="hash"/> was produced from the same <paramref name="data"/>. /// </summary> /// <param name="hasher">The hasher.</param> /// <param name="data">The data, which hash must be verified.</param> /// <param name="hash">The hash to be tested.</param> /// <exception cref="System.Security.Cryptography.CryptographicException">Thrown when the hash is not valid.</exception> public static void VerifyHash( this IHasher hasher, Guid[] data, byte[] hash) { if (hasher == null) { throw new ArgumentNullException(nameof(hasher)); } if (data == null && hash != null) { throw new CryptographicException(Resources.InvalidHash); } hasher.VerifyHash(ToByteArray.Convert(data), hash); }
/// <summary> /// Verifies that the passed <paramref name="hash"/> was produced from the same <paramref name="data"/>. /// </summary> /// <param name="hasher">The hasher.</param> /// <param name="data">The data, which hash must be verified.</param> /// <param name="hash">The hash to be tested.</param> /// <exception cref="System.Security.Cryptography.CryptographicException">Thrown when the hash is not valid.</exception> public static void VerifyHash( this IHasher hasher, Guid data, byte[] hash) { if (hasher == null) { throw new ArgumentNullException(nameof(hasher)); } if (hash == null) { throw new ArgumentNullException(nameof(hash)); } hasher.VerifyHash(ToByteArray.Convert(data), hash); }
/// <summary> /// Verifies that the passed <paramref name="hash"/> was produced from the same <paramref name="data"/>. /// </summary> /// <param name="hasher">The hasher.</param> /// <param name="data">The data, which hash must be verified.</param> /// <param name="hash">The hash to be tested.</param> /// <returns><c>true</c> if the hash has a value that was produced rom the <paramref name="data"/>; <c>false</c> otherwise.</returns> public static bool TryVerifyHash( this IHasher hasher, DateTime[] data, byte[] hash) { if (hasher == null) { throw new ArgumentNullException(nameof(hasher)); } if (data == null && hash != null) { throw new CryptographicException(Resources.InvalidHash); } return(hasher.TryVerifyHash(ToByteArray.Convert(data), hash)); }
/// <summary> /// Verifies that the passed <paramref name="hash"/> was produced from the same <paramref name="data"/>. /// </summary> /// <param name="hasher">The hasher.</param> /// <param name="data">The data, which hash must be verified.</param> /// <param name="hash">The hash to be tested.</param> /// <returns><c>true</c> if the hash has a value that was produced rom the <paramref name="data"/>; <c>false</c> otherwise.</returns> public static bool TryVerifyHash( this IHasher hasher, DateTime data, byte[] hash) { if (hasher == null) { throw new ArgumentNullException(nameof(hasher)); } if (hash == null) { throw new ArgumentNullException(nameof(hash)); } return(hasher.TryVerifyHash(ToByteArray.Convert(data), hash)); }