Home > other >  DES cryptography to speak only in the textbooks to set up the 64 - bit key, why, in c # program ment
DES cryptography to speak only in the textbooks to set up the 64 - bit key, why, in c # program ment

Time:10-08

Try
{
Byte [] rgbKey=Encoding. UTF8. GetBytes (the encryptKey. Substring (0, 8));//
//rgbIV unlike rgbKey can, here only to simple, readers can modify
Byte [] rgbIV=Encoding. UTF8. GetBytes (the encryptKey. Substring (0, 8));
Byte [] inputByteArray=Encoding. UTF8. GetBytes (encryptString);//this is to encrypt the data part of the

DESCryptoServiceProvider dCSP=new DESCryptoServiceProvider ();
MemoryStream mStream=new MemoryStream ();
CryptoStream cStream=new CryptoStream (mStream, dCSP CreateEncryptor (rgbKey, rgbIV), CryptoStreamMode. Write);

CStream. Write (inputByteArray, 0, inputByteArray. Length);
CStream. FlushFinalBlock ();
Return the Convert. ToBase64String (mStream ToArray ());
}
Catch//try to catch is a fixed usage, the try is normal code, if abnormal, turned to execute catch
{
Return encryptString;
}

For this part of the des encryption code, why CreateEncryptor function of variables in addition to the key and iv? This CreateEncryptor function should be encryption function, something to do with the teaching material in different way? Teaching material is provided by the des design scheme of the beginning, did not put forward the concept of iv, I am a newcomer, there are c, just contact with c #, also please explain in detail a few great god, I would be grateful, and I also will be very hard, the ranks of information security at an early date to help more people,
  • Related