/// <summary> /// Create a transformer to encrypt or decrypt data /// </summary> /// <param name="rgbKey">The secret key used for transforming</param> /// <returns>A symmetric decryptor or encryptor object.</returns> private ICryptoTransform CreateTransformer(byte[] rgbKey) { this.Key = rgbKey; RC4CryptoTransform transformer = new RC4CryptoTransform(rgbKey); return(transformer); }
/// <summary> /// Create a transformer to encrypt or decrypt data /// </summary> /// <param name="rgbKey">The secret key used for transforming</param> /// <returns>A symmetric decryptor or encryptor object.</returns> private ICryptoTransform CreateTransformer(byte[] rgbKey) { this.Key = rgbKey; RC4CryptoTransform encryptor = new RC4CryptoTransform(); IntPtr transKey = IntPtr.Zero; bool status = NativeMethods.CryptDuplicateKey(keyHandle, IntPtr.Zero, 0, ref transKey); if (!status) { throw new CryptographicException("CryptDuplicateKey fails:" + Helper.GetLastErrorCodeString()); } encryptor.keyHandle = transKey; return((ICryptoTransform)encryptor); }
/// <summary> /// Create a transformer to encrypt or decrypt data /// </summary> /// <param name="rgbKey">The secret key used for transforming</param> /// <returns>A symmetric decryptor or encryptor object.</returns> private ICryptoTransform CreateTransformer(byte[] rgbKey) { this.Key = rgbKey; RC4CryptoTransform encryptor = new RC4CryptoTransform(); IntPtr transKey = IntPtr.Zero; bool status = NativeMethods.CryptDuplicateKey(keyHandle, IntPtr.Zero, 0, ref transKey); if (!status) { throw new CryptographicException("CryptDuplicateKey fails:" + Helper.GetLastErrorCodeString()); } encryptor.keyHandle = transKey; return (ICryptoTransform)encryptor; }