HMAC-MD5 C # implementation

xiaoxiao2021-03-06  81

Due to the need for work, a C # version of the HMAC-MD5 encryption algorithm is written. / ** * * HMAC_MD5 password encryption algorithm * * / public byte [] hmac_md5 (string password) {byte [] b_tmp; byte [] b_tmp1; if (password == null) {Return null;} Byte [] Digest = new byte [512]; byte [] k_ipad = new byte [64]; byte [] k_opad = new byte [64]; byte [] source = system.text.asciiencoding.ascii.getbytes (password); system. Security.cryptography.md5 shainner = new md5cryptoServiceProvider (); for (int i = 0; i <64; i ) {k_ipad [i] = 0 ^ 0x36; k_opad [i] = 0 ^ 0x5c;}

Try {if (Source.Length> 64) {Shainner = new md5cryptoserviceProvider (); source = shainner.computehash (} for (int i = 0; i

/ ** * * Fill byte * * / public byte [] adding (byte [] a, byte [] b) {byte [] c = new byte [a.length b.ley "; a.couth p (c, 0); B.CopyTo (C, A.Length); Return C;

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

New Post(0)