// Encrypted string, pay attention to the length of StrenchKey is 8 bits (if you want to increase or reduce the length length, adjust the length of the IV is) Public String Desencrypt (String StRTEXT, STRING Strencrkey)
// Decrypt string, pay attention to Strench, the length of 8 bits (if you want to increase or reduce the length length, adjust the length of the IV)
Public String Desdecrypt (String STRTEXT, STRING SDECRKEY)
// Encrypted data file, pay attention to the length of Strencrkey (if you want to add or reduce the length length, adjust the length of IV)
Public void desencrypt (string m_infilepath, string m_outfilepath, string strencrkey)
// Decrypt data file, pay attention to StrenchKey length of 8 bits (if you want to increase or reduce the length length, adjust the length of IV)
Public void deSDecrypt (String M_INFILEPATH, STRING M_OUTFILEPATH, STRING SDECRKEY)
// MD5 encryption
Public String Md5encrypt (String Strtext)
* /
/ ************************************************** *************************************************** * CRYPTOGRAPHY CLASS for CRYPTOGRAPHY Author: Jim E_mail: tjq_tang@hotmail.com * Thanks: * URI: * * ******************************************** *********************************************************** **** / using system; using system.security.cryptography; using system.io; using system.windows.form;
Namespace NetBee.Classes.security {///
} ///
} catch (system.exception error) {messagebox.show (error.Message); return "error:" error.Message "/ r";}} ///
{0x12, 0x34, 0x56, 0x78, 0x90, 0xAb, 0xcd, 0xef}; Try {bykey = system.text.Encoding.utf8.getbytes (Strencrkey.substring (0,8)); FILESTREAM FIN = New FileStream (m_infilepath, FileMode.Open, FileAccess.Read); FileStream fout = new FileStream (m_OutFilePath, FileMode.OpenOrCreate, FileAccess.Write); fout.SetLength (0);. // Create variables to help with read and write byte [] bin = new Byte [100]; // this is interface for the encryption. long rdlen = 0; // this is the total number of bytes Written. Long totlen = fin.length; // this is the total length of the input file. int len; // This is the number of bytes to be written at a time.DES des = new DESCryptoServiceProvider (); CryptoStream encStream = new CryptoStream (fout, des.CreateEncryptor (byKey, IV), CryptoStreamMode.Write);
// read from the input file, the Encrypt and Write to the output file. While (Rdlen ENCSTream.close (); fout.close (); fin.close (); } catch (system.exception error) {messagebox.show (Error.Message.toString ()); }}} /// // read from the input file, the Encrypt and Write to the output file. While (Rdlen ENCSTream.close (); fout.close (); fin.close ();