Send a method of encryption

xiaoxiao2021-03-06  54

Disclaimer: Recently, many websites quote their own articles have been omitted, and the author information is omitted. Please quote the author's website not to omit the author's information. 32; // Declare the separation length of the encrypted character before and after the PUBLIC Const Int Len = 4;

/// method effect: Encrypted /// // // /// /// /// /// /// ///////////bit of the encryption: Encrypted Character Public Static Byte [] SourceEncrypt (String Strencrypt) {String Source = Encrypt (strencrypt); // first string first = encrypt (source.substring (0, len)); // second string second = encrypt (Source.Substring (LEN-1, Source.length-Len); // Third string third = Encrypt (source.Substring (source.Length-LEN, LEN)); // four byte [] Random = new byte [LENGTH]; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider (); rng.GetNonZeroBytes (Random); string four = Encrypt (system.text.encoding.ascii.getstring (random)); string all = first second third four; return system.text.Encoding.ascii.getbytes (all);} // end SourceEncrypt

/// method effect: Encrypt the parameters /// // // /////// ///////// /////////////////////bit of the encrypted character public static string encrypt (string strencrypt) {Sha256Managed SHA = New Sha256Managed ); Byte [] value = sha.computehash (system.text.encoding.ascii.getbytes); return system.text.Encoding.ascii.getstring (value);} // end encrypt

/// method effect: Compare parameters /// Parameter: /// String strsource: Original characters /// String Strobject: Target character /// Return Result: Bool Waitages Public Static Bool CompareEncrypt (Byte [] strsource, string strobject) {bool result = true; byte [] strObject = SourceEncrypt (strobject); // strObject = SourceEncrypt (strObject); if ((strSource == null) || (strObject == null) || (strSource.Length ! = strObject.Length)) result = false; else {// strSource = strSource.Substring (0, strSource.Length-LENGTH); // strObject = strObject.Substring (0, strObject.Length-LENGTH); // byte [] Source = system.text.Encoding.ascii.getbytes (strsource); // Byte [] obj = system.text.encoding.ascii.getbytes; byte [] Source = strsource; byte [] obj = strobject; Byte [] obj = strobject ; If (source.Length! = Obj.Length) Result = false; else {for (int i = 0; i

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

New Post(0)