Re: Converting CryptAcquireContext -> System.Security.Cryptography.SymmetricAlgorithm
From: HaukiDog (HaukiDog_at_hotmail.com)
Date: 04/29/03
- Next message: Mike Moore [MSFT]: "RE: UNC file share and NTLM user identity"
- Previous message: Andres Ramirez: "Re: Error"
- In reply to: Pieter Philippaerts: "Re: Converting CryptAcquireContext -> System.Security.Cryptography.SymmetricAlgorithm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: 28 Apr 2003 15:57:27 -0700
Hi again, here is what I have, it's not working. Am I using the hash
correctrly?
public string EncryptTest(string Value, string Key)
{
ASCIIEncoding TextConverter = new ASCIIEncoding();
ARCFourManaged myARCFour = new ARCFourManaged();
byte[] myByteKey = TextConverter.GetBytes(Key);
MD5 md5 = new MD5CryptoServiceProvider();
myARCFour.Key = md5.ComputeHash(myByteKey);
ICryptoTransform encryptor = myARCFour.CreateEncryptor();
MemoryStream msEncrypt = new MemoryStream();
CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor,
CryptoStreamMode.Write);
//Convert the data to a byte array.
Byte [] toEncrypt = TextConverter.GetBytes(Value);
//Write all data to the crypto stream and flush it.
csEncrypt.Write(toEncrypt, 0, toEncrypt.Length);
csEncrypt.FlushFinalBlock();
byte [] encrypted = msEncrypt.ToArray();
string EncryptedString = TextConverter.GetString(encrypted);
return EncryptedString;
}
- Next message: Mike Moore [MSFT]: "RE: UNC file share and NTLM user identity"
- Previous message: Andres Ramirez: "Re: Error"
- In reply to: Pieter Philippaerts: "Re: Converting CryptAcquireContext -> System.Security.Cryptography.SymmetricAlgorithm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]