Symmetrical encryption decryption universal class library function

zhaozj2021-02-16  60

Using system; using system.text; using system.security.cryptography;

Namespace Common {///

/// Encryption Decryption Universal Category Library Function /// CopyRight (C), 2004, Kwklover (伟科) /// File Name: Crypto.cs /// Author: 伟 科 Version: 1.0 Date: April 21, 2004 /// DESCRIPTION: Reprincible General Symmetric Encryption Decryption Function Set /// Public Class Crypto {Private String _CryptText; // Resource Sequence Variable Variables to be encrypted and decrypted Private Byte [] _Cryptkey; // Encryption Decrypt Private Key Variable Private Byte [] _Cryptiv; // Encrypted Decryption Initialization Vector IV Variable

///

/// public string crypttext {set {_crypttext {set {_crypttext = value;} get {return

///

/// encryption private key /// public byte [] cryptkey {set {_cryptkey = value;} get {return _cryptKey;}}

///

/// encrypted initialization vector IV /// public byte [] cryptiv {set {_cryptiv = value;} get {return _cryptiv;}}

Public crypto () {// // Todo: Add constructor logic here //}

///

/// encryption function is used to encrypt the string. The corresponding key and IV are required. /// /// public string encrypt () {string strongText = crypttext; byte [] enkey = cryptkey; Byte [] ENIV = CRYPTIV;

Byte [] INPUTBYTEARRAY = System.Text.Encoding.utf8.getbytes (Strentext);

// You can also create additional decryption class instances, but pay attention to different (length) encryption classes require different key Key and initialization vector IV rijndaelmanaged rmcrypto = new rijndaelManaged ();

MemoryStream ms = new MemoryStream (); CryptoStream cs = new CryptoStream (ms, RMCrypto.CreateEncryptor (EnKey, EnIV), CryptoStreamMode.Write); cs.Write (inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock ();

Return Convert.TOBASE64STRING (ms.toarray ());}

///

/// decryption function is encrypted by encrypted character sequences. The corresponding key and IV are required. /// /// public string Decrypt () {string strDeText = CryptText; byte [] DeKey = CryptKey; byte [] DeIV = CryptIV; byte [] inputByteArray = Convert.FromBase64String strDetext;

// You can also create additional decryption class instances, but pay attention to different encryption classes require different (length) Key Key and initialization vector IV RijndaelManaged RMCrypto = new rijndaelManaged ();

MemoryStream ms = new MemoryStream (); CryptoStream cs = new CryptoStream (ms, RMCrypto.CreateDecryptor (DeKey, DeIV), CryptoStreamMode.Write); cs.Write (inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock ();

Return System.Text.Encoding.utf8.getstring (ms.toarray ());}}} Some of the following data encrypted below, I can't summarize these data into valuable expression, I hope you don't worry. Enlightenment:

Admiral English letters, digital length range encrypted before Chinese characters long range encryption length size 0-150-52416-316-104432-4711-15648-6316-208864-7921-1510880-9516-3012896-1113-35152

转载请注明原文地址:https://www.9cbs.com/read-21700.html

New Post(0)