C MD5加密演算法

2021-05-22 11:04:37 字數 3473 閱讀 5740

以前收集的加密演算法

///

/// md5加密演算法 呼叫方法md5encode.encrypt(smessage)

///

/// 單向加密,沒有解密演算法

/// 適用於短內容加密,加密後不需要再解密的內容

///

///

public class md5encode

else

else

return lshift;

}else}}

if (convert.toboolean((lvalue & m_l2power[31 - ishiftbits])))

else

return lshift;}//

private static long rshift(long lvalue, long ishiftbits)

else

else

return rshift;

}else}}

rshift = (lvalue & 0x7ffffffe) / m_l2power[ishiftbits];

if (convert.toboolean((lvalue & 0x80000000)))

return rshift;}//

private static long rotateleft(long lvalue, long ishiftbits)

private static long addunsigned(long lx, long ly)

else if (convert.toboolean(lx4 | ly4))

else

}else

addunsigned = lresult;

return addunsigned;}//

private static long md5_f(long x, long y, long z)

//private static long md5_g(long x, long y, long z)

//private static long md5_h(long x, long y, long z)

//private static long md5_i(long x, long y, long z)

//private static void md5_ff(ref long a, long b, long c, long d, long x, long s, long ac)

//private static void md5_gg(ref long a, long b, long c, long d, long x, long s, long ac)

//private static void md5_hh(ref long a, long b, long c, long d, long x, long s, long ac)

//private static void md5_ii(ref long a, long b, long c, long d, long x, long s, long ac)

//將原文賦給陣列converttowordarray

private static long converttowordarray(string smessage)

lwordcount = lbytecount / bytes_to_a_word;

lbyteposition = (lbytecount % bytes_to_a_word) * bits_to_a_byte;

lwordarray[lwordcount] = lwordarray[lwordcount] | lshift(0x80, lbyteposition);

lwordarray[lnumberofwords - 2] = lshift(lmessagelength, 3);

lwordarray[lnumberofwords - 1] = rshift(lmessagelength, 29);

converttowordarray = lwordarray;

return converttowordarray;}//

private static string wordtohex(long lvalue)

wordtohex = wordtohex + (("0" + tohex(lbyte)).substring(("0" + tohex(lbyte)).length - 2));

}return wordtohex;

}private static string tohex(long dec)

return strhex;}//

private static string tohex(long hex)

return strhex;

}///

/// md5加密演算法主函式

///

/// 單向不可逆加密

///

///

/// 需要加密的資訊

/// 加密結果

public static string encrypt(string smessage)  //public static string encrypt(string smessage, int stype)

long x = null;

int k = 0;

long aa = 0;

long bb = 0;

long cc = 0;

long dd = 0;

long a = 0;

long b = 0;

long c = 0;

long d = 0;

const int s11 = 7;

const int s12 = 12;

const int s13 = 17;

const int s14 = 22;

const int s21 = 5;

const int s22 = 9;

const int s23 = 14;

const int s24 = 20;

const int s31 = 4;

const int s32 = 11;

const int s33 = 16;

const int s34 = 23;

const int s41 = 6;

const int s42 = 10;

const int s43 = 15;

const int s44 = 21;

x = converttowordarray(smessage); //將原文賦給陣列converttowordarray

a = 0x67452301;

b = 0xefcdab89;

c = 0x98badcfe;

d = 0x10325476;

for (k = 0; k < x.length; k += 16)

//if (stype == 32)

////else

//return md5;}}

C MD5加密方法

using system.security.cryptography md5加密函式 public string md5 string str ms的help using system using system.security.cryptography using system.text clas...

C MD5加密解密

h檔案 cpp檔案 實現,可以在應用的.cpp檔案內打包成函式tokey。如下 只學習了將密碼轉換成秘鑰的過程,下面的md5還包括其他的功能,以後再學習。ifndef md5 h define md5 h include include type define typedef unsigned ch...

C MD5加密與解密

using system.security.cryptography using system.io using system.text md5解密 public string md5decrypt string ptodecrypt,string skey des.key asciiencodin...