컴퓨터 지식 네트워크 - 컴퓨터 지식 - asp 의 MD5 암호는 ASP.NET 의 MD5 암호와 다릅니다

asp 의 MD5 암호는 ASP.NET 의 MD5 암호와 다릅니다

ASP.NET 에서 암호화 방법을 교체하여

이전에 개발 중에도 이런 문제가 발생했던 것을 얻을 수 있습니다.

는 ASP 로 암호화한 후 32 비트이고 ASP.NET 암호화는 31 비트입니다 다음은 32 비트입니다 ..

# regionmd5 _ encrypt 암호화, 16 비트 및 32 비트 암호화

const intbits _ to _ a _

constintbytes _ to _ a _ word = 4;

constintbits _ to _ a _ word = 32;

privatelong [] m _ lonbits = new long [31];

private long [] m _ L2 power = new long [31];

privatelong l shift (long lvalue, long ishiftbits)

{

long

if (ishiftbits = = 0)

{

l shift = lvalue;

return l shift;

}

else

{

if (ishiftbits = = 31) 1)

{

l shift = 0x80000000;

}

else

{

l shift = 0;

}

복귀 l shift;

}

else

{

if (ishiftbits lt; 0 | | ishiftbitsgt; 31)

{

//err.raise6;

}

}

}

if (convert.to boolean ( M _ l2power [31-ishiftbits]))

{

l shift = ((lvalue amp; M _ lonbits [31-(ishiftbits+1)]) * m _ l2power [ishiftbits]) | 0x8000000;

}

else

{

l shift = ((lvalue amp; M _ lonbits [31-ishiftbits]) * m _ l2power [ishiftbits]);

}

복귀 l shift;

}

private long rshift (long lvalue, long ishiftbits)

{<

if (ishiftbits = = 0)

{

rshift = lvalue;

return rshift;

}

else

{

if (ishiftbits = = 31) 0x8000000))

{

rshift = 1;

}

else

{

rshift = 0;

}

return rshift;

}

else

{

if (ishiftbits lt; 0 || iShiftBits

Gt; 31)

{

//err.raise6;

}

}

}

rshift = (값 amp; 0x7fffffe)/m _ l2power [ishiftbits];

if (convert. to boolean ((lvalue amp; 0x8000000))

{

rshift = (rshift | (0x40000000/m _ l2power [

}

return rshift;

}

private long rotate left (long lvalue, long ishiftbits)

RotateLeft = LShift(lValue, iShiftBits) | RShift(lValue, (32-iShiftBits));))

return rotate left;

}

private long addunsigned (long LX, long ly)

{

longlx4 = 0;

longly4 = 0;

longlx8 = 0;

longly8 = 0;

long lresult = 0;

lx8 = lxamp; 0x8000000;

ly8 = lyamp; 0x8000000;

lx4 = lxamp; 0x4000000;

ly4 = lyamp; 0x4000000;

lresult = (lxamp; 0x3FFFFFFF)+(lY amp;; 0x3 fffffff);

if (convert. to boolean (lx4 amp; Ly4))

{

lresult = lresult 0x80000000

Lx8 ly8;

}

elseif (convert.to boolean (lx4 | ly4))

{< 0x40000000))

{

lresult = lresult 0xc0000000 lx8 ly8;

}

else

{

lresult = lresult 0x4000t

}

}

else

{

lresule

}

addunsigned = lresult;

return addunsigned;

}

privatelong MD5 _ f (long x, long y, long z)

{<

MD5 _ f = (x amp; Y) y) | ((~x) amp;; Z);

return MD5 _ f;

}

privatelong MD5 _ g (long x, long y, long z)

{<

MD5 _ g = (x amp; Z) | (y amp; (~ z));

return MD5 _ g;

}

privatelong MD5 _ h (long x, long y, long z)

{<

MD5 _ h = (x y z);

return MD5 _ h;

}

privatelong MD5 _ I (long x, long y, long z)

{<

> MD5 _ I = (y (x | (~ z));

return MD5 _ I;

}

private void MD5 _ ff (ref long a, long b, long c, long d, long x, long Longac)

{

a = addunsigned (a, addunsigned (addunsigned (MD5 _ f)

a = RotateLeft(a, s);

a = AddUnsigned(a, b);

}

private void MD5 _ gg (reflong a, long b, long c, long d, long x, long Longac)

{

a = addunsigned (a, addunsigned (addunsigned (MD5 _ g)

a = RotateLeft(a, s);

a = AddUnsigned(a, b);

}

private void MD5 _ hh (ref long a, long b, long c, long d, long x, long Longac)

{

a = addunsigned (a, addunsigned (addunsigned (MD5 _ h)

a = RotateLeft(a, s);

a = AddUnsigned(a, b);

}

private void MD5 _ ii (ref long a, long b, long c, long d, long x, long Longac)

{

a = addunsigned (a, addunsigned (addunsigned (MD5 _ I)

a = RotateLeft(a, s);

a = AddUnsigned(a, b);

}

privatelong [] converttowordarray (strings message)

Ull;;

intlmessagelength = 0;

intlnumberofwords = 0;

long [] lwordarray = null;

intlbyteposition = 0;

intlbytecount = 0;

intlwordcount = 0;

constintmodulus _ bits = 512;

const intcongruent _ bits = 448;

lmessagelength = s message.length;

lnumberofwords = (((lmessagelength+((modulus _ bits-congruent _ bits)/bits)

lwordarray = new long [lnumberofwords];

lbyteposition = 0;

lbytecount = 0;

while (lbytecount lt; Lmessagelength)

{

lwordcount = lbytecount/bytes _ to _ a _ word >

lbyteposition = (lbytecountbytes _ to _ a _ word) * bits _ to _ a _ byte;

lwordarray [lwordcount] = lwordarray [lwordcount] | l shift (convert.to byte (s messe)

lbytecount = lbytecount+1;

}

lwordcount = lbytecount/bytes _ to _ a _ word;

lbyteposition = (lbytecountbytes _ to _ a _ word) * bits _ to _ a _ byte;

lwordarray [lwordcount] = lwordarray [lwordcount] | l shift (0x80, lByte

위치);

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

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

converttowordarray = lwordarray;

return converttowordarray;

}

private string wordtohex (long lvalue)

{

<;

longlbyte = 0;

intlcount = 0;

for (lcount = 0; LCount lt;; = 3; Lcount++)

{

lbyte = rshift (lvalue, lcount * bits _ to _ a _ M _ lonbits [bits _ to _ a _ byte-1];

wordtohex = wordtohex+(("0"+to hex (lbyte)). substring (("0"+to hehex)

}

return wordtohex;

}

private string to hex (long dec)

{

sp

while (decgt; 0)

{

strhex = tohex (dec 16)+strhex;

dec = dec/16;

}

return strhex;

}

private string to hex (long hex)

{

sp

스위치 (hex)

{

case10: strhex = "a"; 브레크;

case11: strhex = "b"; 브레아

K;

case12: strhex = "c"; 브레크;

case13: strhex = "d"; 브레크;

case14: strhex = "e"; 브레크;

case15: strhex = "f"; 브레크;

default: strhex = hex.tostring (); 브레크;

}

return strhex;

}

public string MD5 _ encrypt (string s message, intstype)

< p

for (int I = 0; I lt;; = 30; I++)

{

m _ lonbits [I] = convert.toint64 (math.pow (2,

m _ l2power [I] = convert.toint64 (math.pow (2, i)););

}

long [] x = null;

int k = 0;

longaa = 0;

longbb = 0;

longcc = 0;

long DD = 0;

long a = 0;

long b = 0;

long c = 0;

long d = 0;

constints11 = 7;

constints12 = 12;

constints13 = 17;

constints14 = 22;

constints21 = 5;

constints22 = 9;

constints23 = 14;

constints24 = 20;

constints31 = 4;

constints32 = 11;

Constints33 = 16;

constints34 = 23;

constints41 = 6;

constints42 = 10;

constints43 = 15;

constints44 = 21;

x = converttowordarray (smessage);

a = 0x67452301;

b = 0xefcdab89;

c = 0x98 badcfe;

d = 0x10325476;

for (k = 0; K lt;; X.Length;; K+= 16)

{

aa = a;

bb = b;

cc = c;

DD = d;

MD5 _ ff (참조 a, b, c, d, x[k+0], s11,0xd76 aa 478);

md5_FF(ref d, a, b, c, x[k+1], s12,0xe8c7b756);

MD5 _ ff (참조 c, d, a, b, x[k+2], s13,0x242070db);

MD5 _ ff (참조 b, c, d, a, x[k+3], s14,0xc1 bdceee);

MD5 _ ff (참조 a, b, c, d, x[k+4], s11,0xf57c0faf);

MD5 _ ff (참조 d, a, b, c, x[k+5], s12,0x4787c62a);

MD5 _ ff (참조 c, d, a, b, x[k+6], s13,0xa 8304613);

MD5 _ ff (참조 b, c, d, a, x[k+7], s14,0x FD 469501);

MD5 _ ff (참조 a, b, c, d, x[k+8], s11,0x698098d8);

MD5 _ ff (참조 d, a, b, c, x[k+9], s12,0x8b44f7af);

MD5 _ ff (참조 c, d, a, b, x[k+10], s13,0 xfff 5bb1); < /p

>

md5_FF(ref b, c, d, a, x[k+11], s14,0x895cd7be);

MD5 _ ff (참조 a, b, c, d, x[k+12], s11,0x6b 901122);

MD5 _ ff (참조 d, a, b, c, x[k+13], s12,0x FD 987193);

MD5 _ ff (참조 c, d, a, b, x[k+14], s13,0xa 679438e);

md5_FF(ref b, c, d, a, x[k+15], s14,0x49b40821);

MD5 _ gg (참조 a, b, c, d, x[k+1], s21,0xf61e2562);

MD5 _ gg (참조 d, a, b, c, x[k+6], s22,0xc040b340);

MD5 _ gg (참조 c, d, a, b, x[k+11], s23,0x265e5a51);

md5_GG(ref b, c, d, a, x[k+0], s24,0x 0xE9B6C7AA);;

MD5 _ gg (참조 a, b, c, d, x[k+5], s21,0xd62f 105d);

MD5 _ gg (참조 d, a, b, c, x[k+10], s22,0x2441453);

MD5 _ gg (참조 c, d, a, b, x[k+15], s23,0xd8 a1 e681);

md5_GG(ref b, c, d, a, x[k+4], s24,0xe7d 3f bc8);

MD5 _ gg (참조 a, b, c, d, x[k+9], s21,0x21e 1cde6);

md5_GG(ref d, a, b, c, x[k+14], s22,0xc33707d6);

MD5 _ gg (참조 c, d, a, b, x[k+3], s23,0xf4 d 50d87);

MD5 _ gg (참조 b, c, d, a, x[k+8], s24,0x455 a14ed);

MD5 _ gg (참조 a, b, c, d, x[k+13], s21,0x a 9e3e905);

md5_GG(ref d, a, b, c, x[k+2], s22,0 xfce fa 3f8);

Md5_GG(ref c, d, a, b, x[k+7], s23,0x676 f02d9);

MD5 _ gg (참조 b, c, d, a, x[k+12], s24,0x8d2 a4 c8a);

MD5 _ hh (참조 a, b, c, d, x[k+5], s31,0x fffa 3942);

MD5 _ hh (참조 d, a, b, c, x[k+8], s32,0x8771 f681);

MD5 _ hh (참조 c, d, a, b, x[k+11], s33,0x6d 9d 6122);

MD5 _ hh (참조 b, c, d, a, x[k+14], s34,0 xfde 5380c);

MD5 _ hh (참조 a, b, c, d, x[k+1], s31,0xa4 beea 44);

MD5 _ hh (참조 d, a, b, c, x[k+4], s32,0x4b decf a9);

MD5 _ hh (참조 c, d, a, b, x[k+7], s33,0xf6 bb4b60);

MD5 _ hh (참조 b, c, d, a, x[k+10], s34,0 xbebfbc70);

MD5 _ hh (참조 a, b, c, d, x[k+13], s31,0x289 b7ec6);

MD5 _ hh (참조 d, a, b, c, x[k+0], s32,0 xeaa 127fa);

MD5 _ hh (참조 c, d, a, b, x[k+3], s33,0xd4 ef 3085);

MD5 _ hh (참조 b, c, d, a, x[k+6], s34,0x4881d05);

md5_HH(ref a, b, c, d, x[k+9], s31,0x d 9 d 4d 039);

MD5 _ hh (참조 d, a, b, c, x[k+12], s32,0xe6 db99e5);

MD5 _ hh (참조 c, d, a, b, x[k+15], s33,0x1fa 27cf8);

md5_HH(ref b, c, d, a, x[k+2], s34,0xc4 ac5665);

MD5 _ ii (참조 a, b, c, d, x[k+0], s41,0xf 429244);

Md5_II(ref d, a, b, c, x[k+7], s42,0x432aff97);

MD5 _ ii (참조 c, d, a, b, x[k+14], s43,0xab9423a7);

md5_II(ref b, c, d, a, x[k+5], s44,0xfc 93a039);

MD5 _ ii (참조 a, b, c, d, x[k+12], s41,0x655b59c3);

MD5 _ ii (참조 d, a, b, c, x[k+3], s42,0x8f0 ccc92);

MD5 _ ii (참조 c, d, a, b, x[k+10], s43,0xf feff47d);

MD5 _ ii (참조 b, c, d, a, x[k+1], s44,0x85845dd1);

MD5 _ ii (참조 a, b, c, d, x[k+8], s41,0x6fa87e4f);

md5_II(ref d, a, b, c, x[k+15], s42,0xfe 2ce6e0);

MD5 _ ii (참조 c, d, a, b, x[k+6], s43,0xa 3014314);

MD5 _ ii (참조 b, c, d, a, x[k+13], s44,0x4e0811a1);

MD5 _ ii (참조 a, b, c, d, x[k+4], s41,0xf 7537e82);

MD5 _ ii (참조 d, a, b, c, x[k+11], s42,0xbd3 af 235);

MD5 _ ii (참조 c, d, a, b, x[k+2], s43,0x2ad 7d 2bb);

md5_II(ref b, c, d, a, x[k+9], s44,0xeb86d391);

a = AddUnsigned(a, aa);

b = AddUnsigned(b, bb);

c = AddUnsigned(c, cc);

d = AddUnsigned(d, DD);

}

if (유형 = = 32)

{

MD5 = (

Tohex (b))+(wordtohex (c))+(wordtohex (d)). tolower ();

}

else

{

MD5 = ((wordtohex (b)

}

return MD5;

}

#endregion

上篇: accp 소프트웨어 엔지니어(핵심 소프트웨어 개발 기술 마스터) 下篇: Dota2에서 플레이하는 영상을 다운로드하는 방법을 알려주세요.
관련 내용