MD5加密解密

2021-06-08 19:14:41 字數 1270 閱讀 8515

protected void page_load(object sender, eventargs e)

]", s0);

console.writeline("加密: ", s1);

console.writeline("解密: ", s2);

}///md5解密

public string md5decrypt(string ptodecrypt, string skey)

des.key = asciiencoding.ascii.getbytes(skey);

des.iv = asciiencoding.ascii.getbytes(skey);

memorystream ms = new memorystream();

cryptostream cs = new cryptostream(ms, des.createdecryptor(), cryptostreammode.write);

cs.write(inputbytearray, 0, inputbytearray.length);

cs.flushfinalblock();

stringbuilder ret = new stringbuilder();

return system.text.encoding.default.getstring(ms.toarray());

}// 建立key

public string generatekey()

// 加密字串

public string encryptstring(string sinputstring, string skey)

// 解密字串

public string decryptstring(string sinputstring, string skey)

descryptoserviceprovider des = new descryptoserviceprovider();

des.key = asciiencoding.ascii.getbytes(skey);

des.iv = asciiencoding.ascii.getbytes(skey);

icryptotransform desencrypt = des.createdecryptor();

byte result = desencrypt.transformfinalblock(data, 0, data.length);

return encoding.utf8.getstring(result);}}

}

MD5加密解密

using system using system.text using system.io using system.security.cryptography class class1 txtkey txtiv kl7zgtm1dvq 設定加密iv btnivgen console.writel...

MD5加密解密

using system using system.text using system.io using system.security.cryptography class class1 txtkey txtiv kl7zgtm1dvq 設定加密iv btnivgen console.writel...

MD5,加密解密

在工作中有時會用到把密碼md5加密後放入資料庫的情況,咱們現在就來說說如何md5加密。先說說 public static string string2md5 string instr catch exception e char chararray instr.tochararray byte by...