using System; using System.Text; using System.Globalization; using System.Security.Cryptography; using System.Windows.Forms; namespace Jh.Encrypts {public class JhEncrypt {/// /// /// constructor summary> public jhencrypt () {} /// /// Using the default key string encryption /// summary> /// Ming Text param> /// Ciphertext returns> public static string encrypt (String Original) {Return Encrypt (Original, "Jasonheung");} /// /// Using the default key decryption ///// summary> /// Ciphertext param> /// 明文 returns> public static string decrypt (string original) {Return Decrypt (Original, "Jasonheung", System.text.Encoding.default);} /// /// Use a given key to decrypt /// summary> /// Ciphertext param> / // Key param> /// clear text returns> public static string decrypt (string original, string key) {Return Decrypt (Original, Key, System.Text. Encoding.default);} /// /// Use the default key to decrypt, return to the specified encoding method clear text /// summary> /// Ciphertext param> /// encoding method param> /// Returns> Public Static String Decrypt (String Original, Encoding Encoding) {Return Decrypt (Original, "Jasonheung", Encoding;} /// /// Use a given key encryption //// summary> / // Original text param> /// Key param> ///
Character encoding scheme param> /// ciphertext returns> public static string encrypt (string original, string key) {byte [] buff = system.text.encoding.default.getbytes (Original); byte [] KB = system.text.encoding.default.getbytes (key); Return Convert.TOBASE64STRING (Encrypt (BUFF, KB));} /// /// Use a given key to decrypt /// < / summary> /// ciphertext param> /// Key param> /// character encoding embodiment param> /// plain returns> public static string Decrypt (string encrypted, string key, encoding encoding) {byte [] buff = Convert.FromBase64String (encrypted); byte [] kb = System. Text.Encoding.default.getbytes (key); return encoding.getstring (Decrypt (BUFF, KB));} /// /// Generate MD5 summary /// summary> /// data source param> /// summary returns> public static byte [] MakeMD5 (byte [] original) {MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider (); byte [] keyhash = Hashmd5.computehash (ORIGINAL); Hashmd5 = NULL; RETURN Keyhash;} /// /// Using a given key encrypted //// summary> /// clear text < / param> /// Key param> /// Ciphertext returns> public static bottypt (byte [] original, Byte [] key) { TripleDescryptoserviceProvider DES = New TripEDescryptoToServiceProvider (); des.key = makemd5 (key); des.mode = ciphermode.ecb;