Use DES, MD5 encryption. Decryption. String. File

zhaozj2021-02-16  47

/ * Use DES, MD5 to the string, data file encryption.

// 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 {///

/// Cryptography /// public class Cryptography {public Cryptography () {} /// /// Encrypt the string /// Attention : Key Must Be 8 Bits /// /// string /// key /// public string desencrypt (string stratext, string strencrkey) {byte [] bykey = null; byte [] iv = {0x12, 0x34, 0x56, 0x78, 0x90, 0xAb, 0xcd, 0xEf}; try {bykey = System.Text.Encoding.UTF8.GetBytes (strEncrKey.Substring (0,8)); DESCryptoServiceProvider des = new DESCryptoServiceProvider (); byte [] inputByteArray = Encoding.UTF8.GetBytes (strText); MemoryStream ms = new MemoryStream (); CryptoStream cs = new CryptoStream (ms, des.CreateEncryptor (byKey, IV), CryptoStreamMode.Write); cs.Write (inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock (); return Convert.ToBase64String (ms.ToArray ( ));

} Catch (system.exception error) {messagebox.show (error.Message); return "error:" error.Message "/ r";}} ///

/// Decrypt string /// attention: Key Must Be 8 Bits /// /// Decrypt string /// /// encrypt files /// attention: key must be 8 bits /// /// Encrypt File Path /// Output file /// Decrypt filepath /// Output filepath /// 转载请注明原文地址:https://www.9cbs.com/read-26307.html

New Post(0)