/// <summary> /// Decrypts the <paramref name="encrypted"/> text to a <see cref="byte"/> value. /// </summary> /// <param name="cipher">The cipher.</param> /// <param name="encrypted">The encrypted text.</param> /// <returns>The decrypted value.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="cipher"/> or <paramref name="encrypted"/> are <see langword="null"/>.</exception> /// <exception cref="ArgumentException">If <paramref name="encrypted"/> does not represent a valid encrypted <see cref="byte"/> value.</exception> public static byte DecryptByte( this ICipher cipher, byte[] encrypted) { if (cipher == null) { throw new ArgumentNullException(nameof(cipher)); } if (encrypted == null) { throw new ArgumentNullException(nameof(encrypted)); } var decrypted = cipher.Decrypt(encrypted); if (decrypted.Length < 1) { throw new ArgumentException(Resources.InvalidEncryptedValue); } return(FromByteArray.ToByte(decrypted)); }