Procurar
Palavras-chaves
Últimos assuntos
Tópicos mais visitados
Tópicos semelhantes
ASP – Login com MD5
Página 1 de 1
ASP – Login com MD5
Autenticação de Usuário
Este método pode ser usado para autenticar usuários, permitindo-lhes escrevendo seu endereço de e-mail e senha. Este método usa algoritmo MD5 para enviar a senha criptografada.
Muitos sites usam a autenticação básica com os arquivos. htaccess ou formulários web simples, combinadas com cookies para autenticar seus usuários. Apenas alguns deles usam um servidor HTTPS para enviar os dados.Um usuário mal intensionado pode dar um sniffing de pacotes na rede, e facilmente capturar as senhas, e usá-lo para obter acesso às contas. Vamos criar um “hash” da senha antes de enviá-lo.
Um seed é incluído na página onde o usuário está sendo solicitado para sua senha. Uma cópia seed é armazenada no objeto de sessão no lado do servidor. Quando o usuário envia a página, um javascript calcula o hash MD5 da seed e a senha:
hash = MD5 (senha de sementes)
O endereço de e-mail e o hash são enviados para o servidor. Quando o servidor recebe esses dados, ele lê a senha para o e-mail digitado no banco de dados, e calcula o hash utilizando a seed que é armazenado no objeto Session.
Ambos os hashes são comparados, e se eles são iguais, o usuário está sendo concedido o acesso ao site.
login.asp
<%
If Session(“autent”) = “true” Then
Response.Redirect “seguro.asp”
Response.End
End If
Randomize Timer
Dim sLeft : Dim sRight
sLeft = CStr(Int(Rnd * 99999)) : If Len(sLeft) < 5 Then sLeft = String(5 – Len(sLeft), “0″) & sLeft
sRight = CStr(Int(Rnd * 99999)) : If Len(sRight)
c
<FORM METHOD=”POST” ACTION=”validar.asp” Id=”formLogin” onSubmit=”md5auth(”);”>
Email:
senha:
logoff.asp
Log out
Você está logado agora.
Cliquehere para fazer login.
md5.asp
<%
Private Const BITS_TO_A_BYTE = 8
Private Const BYTES_TO_A_WORD = 4
Private Const BITS_TO_A_WORD = 32
Private m_lOnBits(30)
Private m_l2Power(30)
m_lOnBits(0) = CLng(1)
m_lOnBits(1) = CLng(3)
m_lOnBits(2) = CLng(7)
m_lOnBits(3) = CLng(15)
m_lOnBits(4) = CLng(31)
m_lOnBits(5) = CLng(63)
m_lOnBits(6) = CLng(127)
m_lOnBits(7) = CLng(255)
m_lOnBits( = CLng(511)
m_lOnBits(9) = CLng(1023)
m_lOnBits(10) = CLng(2047)
m_lOnBits(11) = CLng(4095)
m_lOnBits(12) = CLng(8191)
m_lOnBits(13) = CLng(16383)
m_lOnBits(14) = CLng(32767)
m_lOnBits(15) = CLng(65535)
m_lOnBits(16) = CLng(131071)
m_lOnBits(17) = CLng(262143)
m_lOnBits(18) = CLng(524287)
m_lOnBits(19) = CLng(1048575)
m_lOnBits(20) = CLng(2097151)
m_lOnBits(21) = CLng(4194303)
m_lOnBits(22) = CLng(8388607)
m_lOnBits(23) = CLng(16777215)
m_lOnBits(24) = CLng(33554431)
m_lOnBits(25) = CLng(67108863)
m_lOnBits(26) = CLng(134217727)
m_lOnBits(27) = CLng(268435455)
m_lOnBits(28) = CLng(536870911)
m_lOnBits(29) = CLng(1073741823)
m_lOnBits(30) = CLng(2147483647)
m_l2Power(0) = CLng(1)
m_l2Power(1) = CLng(2)
m_l2Power(2) = CLng(4)
m_l2Power(3) = CLng(
m_l2Power(4) = CLng(16)
m_l2Power(5) = CLng(32)
m_l2Power(6) = CLng(64)
m_l2Power(7) = CLng(128)
m_l2Power( = CLng(256)
m_l2Power(9) = CLng(512)
m_l2Power(10) = CLng(1024)
m_l2Power(11) = CLng(2048)
m_l2Power(12) = CLng(4096)
m_l2Power(13) = CLng(8192)
m_l2Power(14) = CLng(16384)
m_l2Power(15) = CLng(32768)
m_l2Power(16) = CLng(65536)
m_l2Power(17) = CLng(131072)
m_l2Power(18) = CLng(262144)
m_l2Power(19) = CLng(524288)
m_l2Power(20) = CLng(1048576)
m_l2Power(21) = CLng(2097152)
m_l2Power(22) = CLng(4194304)
m_l2Power(23) = CLng(8388608)
m_l2Power(24) = CLng(16777216)
m_l2Power(25) = CLng(33554432)
m_l2Power(26) = CLng(67108864)
m_l2Power(27) = CLng(134217728)
m_l2Power(28) = CLng(268435456)
m_l2Power(29) = CLng(536870912)
m_l2Power(30) = CLng(1073741824)
Private Function LShift(lValue, iShiftBits)
If iShiftBits = 0 Then
LShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And 1 Then
LShift = &H80000000
Else
LShift = 0
End If
Exit Function
ElseIf iShiftBits 31 Then
Err.Raise 6
End If
If (lValue And m_l2Power(31 – iShiftBits)) Then
LShift = ((lValue And m_lOnBits(31 – (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000
Else
LShift = ((lValue And m_lOnBits(31 – iShiftBits)) * m_l2Power(iShiftBits))
End If
End Function
Private Function RShift(lValue, iShiftBits)
If iShiftBits = 0 Then
RShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And &H80000000 Then
RShift = 1
Else
RShift = 0
End If
Exit Function
ElseIf iShiftBits 31 Then
Err.Raise 6
End If
RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits)
If (lValue And &H80000000) Then
RShift = (RShift Or (&H40000000 \ m_l2Power(iShiftBits – 1)))
End If
End Function
Private Function RotateLeft(lValue, iShiftBits)
RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 – iShiftBits))
End Function
Private Function AddUnsigned(lX, lY)
Dim lX4
Dim lY4
Dim lX8
Dim lY8
Dim lResult
lX8 = lX And &H80000000
lY8 = lY And &H80000000
lX4 = lX And &H40000000
lY4 = lY And &H40000000
lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)
If lX4 And lY4 Then
lResult = lResult Xor &H80000000 Xor lX8 Xor lY8
ElseIf lX4 Or lY4 Then
If lResult And &H40000000 Then
lResult = lResult Xor &HC0000000 Xor lX8 Xor lY8
Else
lResult = lResult Xor &H40000000 Xor lX8 Xor lY8
End If
Else
lResult = lResult Xor lX8 Xor lY8
End If
AddUnsigned = lResult
End Function
Private Function F(x, y, z)
F = (x And y) Or ((Not x) And z)
End Function
Private Function G(x, y, z)
G = (x And z) Or (y And (Not z))
End Function
Private Function H(x, y, z)
H = (x Xor y Xor z)
End Function
Private Function I(x, y, z)
I = (y Xor (x Or (Not z)))
End Function
Private Sub FF(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub GG(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub HH(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub II(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Function ConvertToWordArray(sMessage)
Dim lMessageLength
Dim lNumberOfWords
Dim lWordArray()
Dim lBytePosition
Dim lByteCount
Dim lWordCount
Const MODULUS_BITS = 512
Const CONGRUENT_BITS = 448
lMessageLength = Len(sMessage)
lNumberOfWords = (((lMessageLength + ((MODULUS_BITS – CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD)
ReDim lWordArray(lNumberOfWords – 1)
lBytePosition = 0
lByteCount = 0
Do Until lByteCount >= lMessageLength
lWordCount = lByteCount \ BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)
lByteCount = lByteCount + 1
Loop
lWordCount = lByteCount \ BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(&H80, lBytePosition)
lWordArray(lNumberOfWords – 2) = LShift(lMessageLength, 3)
lWordArray(lNumberOfWords – 1) = RShift(lMessageLength, 29)
ConvertToWordArray = lWordArray
End Function
Private Function WordToHex(lValue)
Dim lByte
Dim lCount
For lCount = 0 To 3
lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE – 1)
WordToHex = WordToHex & Right(“0″ & Hex(lByte), 2)
Next
End Function
Public Function MD5(sMessage)
Dim x
Dim k
Dim AA
Dim BB
Dim CC
Dim DD
Dim a
Dim b
Dim c
Dim d
Const S11 = 7
Const S12 = 12
Const S13 = 17
Const S14 = 22
Const S21 = 5
Const S22 = 9
Const S23 = 14
Const S24 = 20
Const S31 = 4
Const S32 = 11
Const S33 = 16
Const S34 = 23
Const S41 = 6
Const S42 = 10
Const S43 = 15
Const S44 = 21
x = ConvertToWordArray(sMessage)
a = &H67452301
b = &HEFCDAB89
c = &H98BADCFE
d = &H10325476
For k = 0 To UBound(x) Step 16
AA = a
BB = b
CC = c
DD = d
FF a, b, c, d, x(k + 0), S11, &HD76AA478
FF d, a, b, c, x(k + 1), S12, &HE8C7B756
FF c, d, a, b, x(k + 2), S13, &H242070DB
FF b, c, d, a, x(k + 3), S14, &HC1BDCEEE
FF a, b, c, d, x(k + 4), S11, &HF57C0FAF
FF d, a, b, c, x(k + 5), S12, &H4787C62A
FF c, d, a, b, x(k + 6), S13, &HA8304613
FF b, c, d, a, x(k + 7), S14, &HFD469501
FF a, b, c, d, x(k + , S11, &H698098D8
FF d, a, b, c, x(k + 9), S12, &H8B44F7AF
FF c, d, a, b, x(k + 10), S13, &HFFFF5BB1
FF b, c, d, a, x(k + 11), S14, &H895CD7BE
FF a, b, c, d, x(k + 12), S11, &H6B901122
FF d, a, b, c, x(k + 13), S12, &HFD987193
FF c, d, a, b, x(k + 14), S13, &HA679438E
FF b, c, d, a, x(k + 15), S14, &H49B40821
GG a, b, c, d, x(k + 1), S21, &HF61E2562
GG d, a, b, c, x(k + 6), S22, &HC040B340
GG c, d, a, b, x(k + 11), S23, &H265E5A51
GG b, c, d, a, x(k + 0), S24, &HE9B6C7AA
GG a, b, c, d, x(k + 5), S21, &HD62F105D
GG d, a, b, c, x(k + 10), S22, &H2441453
GG c, d, a, b, x(k + 15), S23, &HD8A1E681
GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8
GG a, b, c, d, x(k + 9), S21, &H21E1CDE6
GG d, a, b, c, x(k + 14), S22, &HC33707D6
GG c, d, a, b, x(k + 3), S23, &HF4D50D87
GG b, c, d, a, x(k + , S24, &H455A14ED
GG a, b, c, d, x(k + 13), S21, &HA9E3E905
GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8
GG c, d, a, b, x(k + 7), S23, &H676F02D9
GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A
HH a, b, c, d, x(k + 5), S31, &HFFFA3942
HH d, a, b, c, x(k + , S32, &H8771F681
HH c, d, a, b, x(k + 11), S33, &H6D9D6122
HH b, c, d, a, x(k + 14), S34, &HFDE5380C
HH a, b, c, d, x(k + 1), S31, &HA4BEEA44
HH d, a, b, c, x(k + 4), S32, &H4BDECFA9
HH c, d, a, b, x(k + 7), S33, &HF6BB4B60
HH b, c, d, a, x(k + 10), S34, &HBEBFBC70
HH a, b, c, d, x(k + 13), S31, &H289B7EC6
HH d, a, b, c, x(k + 0), S32, &HEAA127FA
HH c, d, a, b, x(k + 3), S33, &HD4EF3085
HH b, c, d, a, x(k + 6), S34, &H4881D05
HH a, b, c, d, x(k + 9), S31, &HD9D4D039
HH d, a, b, c, x(k + 12), S32, &HE6DB99E5
HH c, d, a, b, x(k + 15), S33, &H1FA27CF8
HH b, c, d, a, x(k + 2), S34, &HC4AC5665
II a, b, c, d, x(k + 0), S41, &HF4292244
II d, a, b, c, x(k + 7), S42, &H432AFF97
II c, d, a, b, x(k + 14), S43, &HAB9423A7
II b, c, d, a, x(k + 5), S44, &HFC93A039
II a, b, c, d, x(k + 12), S41, &H655B59C3
II d, a, b, c, x(k + 3), S42, &H8F0CCC92
II c, d, a, b, x(k + 10), S43, &HFFEFF47D
II b, c, d, a, x(k + 1), S44, &H85845DD1
II a, b, c, d, x(k + , S41, &H6FA87E4F
II d, a, b, c, x(k + 15), S42, &HFE2CE6E0
II c, d, a, b, x(k + 6), S43, &HA3014314
II b, c, d, a, x(k + 13), S44, &H4E0811A1
II a, b, c, d, x(k + 4), S41, &HF7537E82
II d, a, b, c, x(k + 11), S42, &HBD3AF235
II c, d, a, b, x(k + 2), S43, &H2AD7D2BB
II b, c, d, a, x(k + 9), S44, &HEB86D391
a = AddUnsigned(a, AA)
b = AddUnsigned(b, BB)
c = AddUnsigned(c, CC)
d = AddUnsigned(d, DD)
Next
MD5 = LCase(WordToHex(a) & WordToHex(b) & WordToHex(c) & WordToHex(d))
End Function
%>
seguro.asp
Você está autenticado com o endereço de e-mail:
Click aqui para logout.
validar.asp
Secure Login
<%
If sSeed = “” Then
Response.Write “Sua sessão expirou. Você tem esperado por muito tempo, ou seu navegador não suporta cookies.”
ElseIf sEmailAddress = “” Then
Response.Write “Você não introduzir um endereço de e-mail.”
ElseIf LCase(sEmailAddress) LCase(sValidEmailAddress) Then
Response.Write “Você digitou um endereço de e-mail não registrado.”
ElseIf sHash = “” And sPassword “” Then
If sPassword sValidPassword Then
Response.Write “A senha digitada no incorreta. (Inseguro)”
Else
Response.Write “Login feito com sucesso!
Click aqui para continuar.
Click aqui para logout.”
‘ Store credentials in the Session object
Session(“autent”) = “true”
Session(“auth_emailaddress”) = sEmailAddress
End If
ElseIf sHash “” Then
If sHash sValidHash Then
Response.Write “A senha digitada esta incorreta.”
Else
Response.Write “Login feito com sucesso!
Click aqui para continuar.
Click aqui para logout.”
Session(“autent”) = “true”
Session(“auth_emailaddress”) = sEmailAddress
End If
Else
Response.Write “Ocorreu um erro.”
End If
%>
Voltar
md5.js
function array(n) {
for(i=0;i=0) {
a=a%0×80000000;
a>>=b;
a+=0×40000000>>(b-1);
} else
a>>=b;
return a;
}
function shl1(a) {
a=a%0×80000000;
if (a&0×40000000==0×40000000)
{
a-=0×40000000;
a*=2;
a+=0×80000000;
} else
a*=2;
return a;
}
function shl(a,b) {
a=integer(a);
b=integer(b);
for (var i=0;i=0)
if (t2>=0)
return ((t1&t2)+0×80000000);
else
return (t1&b);
else
if (t2>=0)
return (a&t2);
else
return (a&b);
}
function or(a,b) {
a=integer(a);
b=integer(b);
var t1=(a-0×80000000);
var t2=(b-0×80000000);
if (t1>=0)
if (t2>=0)
return ((t1|t2)+0×80000000);
else
return ((t1|b)+0×80000000);
else
if (t2>=0)
return ((a|t2)+0×80000000);
else
return (a|b);
}
function xor(a,b) {
a=integer(a);
b=integer(b);
var t1=(a-0×80000000);
var t2=(b-0×80000000);
if (t1>=0)
if (t2>=0)
return (t1^t2);
else
return ((t1^b)+0×80000000);
else
if (t2>=0)
return ((a^t2)+0×80000000);
else
return (a^b);
}
function not(a) {
a=integer(a);
return (0xffffffff-a);
}
/* Here begin the real algorithm */
var state = new array(4);
var count = new array(2);
count[0] = 0;
count[1] = 0;
var buffer = new array(64);
var transformBuffer = new array(16);
var digestBits = new array(16);
var S11 = 7;
var S12 = 12;
var S13 = 17;
var S14 = 22;
var S21 = 5;
var S22 = 9;
var S23 = 14;
var S24 = 20;
var S31 = 4;
var S32 = 11;
var S33 = 16;
var S34 = 23;
var S41 = 6;
var S42 = 10;
var S43 = 15;
var S44 = 21;
function F(x,y,z) {
return or(and(x,y),and(not(x),z));
}
function G(x,y,z) {
return or(and(x,z),and(y,not(z)));
}
function H(x,y,z) {
return xor(xor(x,y),z);
}
function I(x,y,z) {
return xor(y ,or(x , not(z)));
}
function rotateLeft(a,n) {
return or(shl(a, n),(shr(a,(32 – n))));
}
function FF(a,b,c,d,x,s,ac) {
a = a+F(b, c, d) + x + ac;
a = rotateLeft(a, s);
a = a+b;
return a;
}
function GG(a,b,c,d,x,s,ac) {
a = a+G(b, c, d) +x + ac;
a = rotateLeft(a, s);
a = a+b;
return a;
}
function HH(a,b,c,d,x,s,ac) {
a = a+H(b, c, d) + x + ac;
a = rotateLeft(a, s);
a = a+b;
return a;
}
function II(a,b,c,d,x,s,ac) {
a = a+I(b, c, d) + x + ac;
a = rotateLeft(a, s);
a = a+b;
return a;
}
function transform(buf,offset) {
var a=0, b=0, c=0, d=0;
var x = transformBuffer;
a = state[0];
b = state[1];
c = state[2];
d = state[3];
for (i = 0; i < 16; i++) {
x[i] = and(buf[i*4+offset],0xff);
for (j = 1; j < 4; j++) {
x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * ;
}
}
/* Round 1 */
a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
d = GG ( d, a, b, c, x[10], S22, 0×2441453); /* 22 */
c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
b = HH ( b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] +=a;
state[1] +=b;
state[2] +=c;
state[3] +=d;
}
function init() {
count[0]=count[1] = 0;
state[0] = 0×67452301;
state[1] = 0xefcdab89;
state[2] = 0x98badcfe;
state[3] = 0×10325476;
for (i = 0; i < digestBits.length; i++)
digestBits[i] = 0;
}
function update(b) {
var index,i;
index = and(shr(count[0],3) , 0x3f);
if (count[0]= 63) {
transform(buffer, 0);
}
}
function finish() {
var bits = new array(;
var padding;
var i=0, index=0, padLen=0;
for (i = 0; i < 4; i++) {
bits[i] = and(shr(count[0],(i * ), 0xff);
}
for (i = 0; i < 4; i++) {
bits[i+4]=and(shr(count[1],(i * ), 0xff);
}
index = and(shr(count[0], 3) ,0x3f);
padLen = (index < 56) ? (56 – index) : (120 – index);
padding = new array(64);
padding[0] = 0×80;
for (i=0;i<padLen;i++)
update(padding[i]);
for (i=0;i<8;i++)
update(bits[i]);
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
digestBits[i*4+j] = and(shr(state[i], (j * ) , 0xff);
}
}
}
/* End of the MD5 algorithm */
function hexa(n) {
var hexa_h = “0123456789abcdef”;
var hexa_c=”";
var hexa_m=n;
for (hexa_i=0;hexa_i<8;hexa_i++) {
hexa_c=hexa_h.charAt(Math.abs(hexa_m)%16)+hexa_c;
hexa_m=Math.floor(hexa_m/16);
}
return hexa_c;
}
var ascii=”01234567890123456789012345678901″ +
” !\”#$%&’()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ”+
“[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~”;
function MD5(entree)
{
var l,s,k,ka,kb,kc,kd;
init();
for (k=0;k<entree.length;k++) {
l=entree.charAt(k);
update(ascii.lastIndexOf(l));
}
finish();
ka=kb=kc=kd=0;
for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*);
for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*);
for (i=8;i<12;i++) kc+=shl(digestBits[15-i], ((i-*);
for (i=12;i<16;i++) kd+=shl(digestBits[15-i], ((i-12)*);
s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);
return s;
}
Autenticação de Usuário
Este método pode ser usado para autenticar usuários, permitindo-lhes escrevendo seu endereço de e-mail e senha. Este método usa algoritmo MD5 para enviar a senha criptografada.
Muitos sites usam a autenticação básica com os arquivos. htaccess ou formulários web simples, combinadas com cookies para autenticar seus usuários. Apenas alguns deles usam um servidor HTTPS para enviar os dados.Um usuário mal intensionado pode dar um sniffing de pacotes na rede, e facilmente capturar as senhas, e usá-lo para obter acesso às contas. Vamos criar um “hash” da senha antes de enviá-lo.
Um seed é incluído na página onde o usuário está sendo solicitado para sua senha. Uma cópia seed é armazenada no objeto de sessão no lado do servidor. Quando o usuário envia a página, um javascript calcula o hash MD5 da seed e a senha:
hash = MD5 (senha de sementes)
O endereço de e-mail e o hash são enviados para o servidor. Quando o servidor recebe esses dados, ele lê a senha para o e-mail digitado no banco de dados, e calcula o hash utilizando a seed que é armazenado no objeto Session.Ambos os hashes são comparados, e se eles são iguais, o usuário está sendo concedido o acesso ao site.
login.asp
<%
If Session(“autent”) = “true” ThenResponse.Redirect “seguro.asp”Response.EndEnd If
Randomize Timer
Dim sLeft : Dim sRightsLeft = CStr(Int(Rnd * 99999)) : If Len(sLeft) < 5 Then sLeft = String(5 – Len(sLeft), “0″) & sLeftsRight = CStr(Int(Rnd * 99999)) : If Len(sRight)c
<FORM METHOD=”POST” ACTION=”validar.asp” Id=”formLogin” onSubmit=”md5auth(”);”>
Email: senha: logoff.asp
Log out
Você está logado agora.Cliquehere para fazer login.
md5.asp
<%
Private Const BITS_TO_A_BYTE = 8Private Const BYTES_TO_A_WORD = 4Private Const BITS_TO_A_WORD = 32
Private m_lOnBits(30)Private m_l2Power(30)
m_lOnBits(0) = CLng(1)m_lOnBits(1) = CLng(3)m_lOnBits(2) = CLng(7)m_lOnBits(3) = CLng(15)m_lOnBits(4) = CLng(31)m_lOnBits(5) = CLng(63)m_lOnBits(6) = CLng(127)m_lOnBits(7) = CLng(255)m_lOnBits( = CLng(511)m_lOnBits(9) = CLng(1023)m_lOnBits(10) = CLng(2047)m_lOnBits(11) = CLng(4095)m_lOnBits(12) = CLng(8191)m_lOnBits(13) = CLng(16383)m_lOnBits(14) = CLng(32767)m_lOnBits(15) = CLng(65535)m_lOnBits(16) = CLng(131071)m_lOnBits(17) = CLng(262143)m_lOnBits(18) = CLng(524287)m_lOnBits(19) = CLng(1048575)m_lOnBits(20) = CLng(2097151)m_lOnBits(21) = CLng(4194303)m_lOnBits(22) = CLng(8388607)m_lOnBits(23) = CLng(16777215)m_lOnBits(24) = CLng(33554431)m_lOnBits(25) = CLng(67108863)m_lOnBits(26) = CLng(134217727)m_lOnBits(27) = CLng(268435455)m_lOnBits(28) = CLng(536870911)m_lOnBits(29) = CLng(1073741823)m_lOnBits(30) = CLng(2147483647)
m_l2Power(0) = CLng(1)m_l2Power(1) = CLng(2)m_l2Power(2) = CLng(4)m_l2Power(3) = CLng(8)m_l2Power(4) = CLng(16)m_l2Power(5) = CLng(32)m_l2Power(6) = CLng(64)m_l2Power(7) = CLng(128)m_l2Power( = CLng(256)m_l2Power(9) = CLng(512)m_l2Power(10) = CLng(1024)m_l2Power(11) = CLng(2048)m_l2Power(12) = CLng(4096)m_l2Power(13) = CLng(8192)m_l2Power(14) = CLng(16384)m_l2Power(15) = CLng(32768)m_l2Power(16) = CLng(65536)m_l2Power(17) = CLng(131072)m_l2Power(18) = CLng(262144)m_l2Power(19) = CLng(524288)m_l2Power(20) = CLng(1048576)m_l2Power(21) = CLng(2097152)m_l2Power(22) = CLng(4194304)m_l2Power(23) = CLng(8388608)m_l2Power(24) = CLng(16777216)m_l2Power(25) = CLng(33554432)m_l2Power(26) = CLng(67108864)m_l2Power(27) = CLng(134217728)m_l2Power(28) = CLng(268435456)m_l2Power(29) = CLng(536870912)m_l2Power(30) = CLng(1073741824)
Private Function LShift(lValue, iShiftBits)If iShiftBits = 0 ThenLShift = lValueExit FunctionElseIf iShiftBits = 31 ThenIf lValue And 1 ThenLShift = &H80000000ElseLShift = 0End IfExit FunctionElseIf iShiftBits 31 ThenErr.Raise 6End If
If (lValue And m_l2Power(31 – iShiftBits)) ThenLShift = ((lValue And m_lOnBits(31 – (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000ElseLShift = ((lValue And m_lOnBits(31 – iShiftBits)) * m_l2Power(iShiftBits))End IfEnd Function
Private Function RShift(lValue, iShiftBits)If iShiftBits = 0 ThenRShift = lValueExit FunctionElseIf iShiftBits = 31 ThenIf lValue And &H80000000 ThenRShift = 1ElseRShift = 0End IfExit FunctionElseIf iShiftBits 31 ThenErr.Raise 6End If
RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits)
If (lValue And &H80000000) ThenRShift = (RShift Or (&H40000000 \ m_l2Power(iShiftBits – 1)))End IfEnd Function
Private Function RotateLeft(lValue, iShiftBits)RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 – iShiftBits))End Function
Private Function AddUnsigned(lX, lY)Dim lX4Dim lY4Dim lX8Dim lY8Dim lResult
lX8 = lX And &H80000000lY8 = lY And &H80000000lX4 = lX And &H40000000lY4 = lY And &H40000000
lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)
If lX4 And lY4 ThenlResult = lResult Xor &H80000000 Xor lX8 Xor lY8ElseIf lX4 Or lY4 ThenIf lResult And &H40000000 ThenlResult = lResult Xor &HC0000000 Xor lX8 Xor lY8ElselResult = lResult Xor &H40000000 Xor lX8 Xor lY8End IfElselResult = lResult Xor lX8 Xor lY8End If
AddUnsigned = lResultEnd Function
Private Function F(x, y, z)F = (x And y) Or ((Not x) And z)End Function
Private Function G(x, y, z)G = (x And z) Or (y And (Not z))End Function
Private Function H(x, y, z)H = (x Xor y Xor z)End Function
Private Function I(x, y, z)I = (y Xor (x Or (Not z)))End Function
Private Sub FF(a, b, c, d, x, s, ac)a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac))a = RotateLeft(a, s)a = AddUnsigned(a, b)End Sub
Private Sub GG(a, b, c, d, x, s, ac)a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac))a = RotateLeft(a, s)a = AddUnsigned(a, b)End Sub
Private Sub HH(a, b, c, d, x, s, ac)a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac))a = RotateLeft(a, s)a = AddUnsigned(a, b)End Sub
Private Sub II(a, b, c, d, x, s, ac)a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac))a = RotateLeft(a, s)a = AddUnsigned(a, b)End Sub
Private Function ConvertToWordArray(sMessage)Dim lMessageLengthDim lNumberOfWordsDim lWordArray()Dim lBytePositionDim lByteCountDim lWordCount
Const MODULUS_BITS = 512Const CONGRUENT_BITS = 448
lMessageLength = Len(sMessage)
lNumberOfWords = (((lMessageLength + ((MODULUS_BITS – CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD)ReDim lWordArray(lNumberOfWords – 1)
lBytePosition = 0lByteCount = 0Do Until lByteCount >= lMessageLengthlWordCount = lByteCount \ BYTES_TO_A_WORDlBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTElWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)lByteCount = lByteCount + 1Loop
lWordCount = lByteCount \ BYTES_TO_A_WORDlBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(&H80, lBytePosition)
lWordArray(lNumberOfWords – 2) = LShift(lMessageLength, 3)lWordArray(lNumberOfWords – 1) = RShift(lMessageLength, 29)
ConvertToWordArray = lWordArrayEnd Function
Private Function WordToHex(lValue)Dim lByteDim lCount
For lCount = 0 To 3lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE – 1)WordToHex = WordToHex & Right(“0″ & Hex(lByte), 2)NextEnd Function
Public Function MD5(sMessage)Dim xDim kDim AADim BBDim CCDim DDDim aDim bDim cDim d
Const S11 = 7Const S12 = 12Const S13 = 17Const S14 = 22Const S21 = 5Const S22 = 9Const S23 = 14Const S24 = 20Const S31 = 4Const S32 = 11Const S33 = 16Const S34 = 23Const S41 = 6Const S42 = 10Const S43 = 15Const S44 = 21
x = ConvertToWordArray(sMessage)
a = &H67452301b = &HEFCDAB89c = &H98BADCFEd = &H10325476
For k = 0 To UBound(x) Step 16AA = aBB = bCC = cDD = d
FF a, b, c, d, x(k + 0), S11, &HD76AA478FF d, a, b, c, x(k + 1), S12, &HE8C7B756FF c, d, a, b, x(k + 2), S13, &H242070DBFF b, c, d, a, x(k + 3), S14, &HC1BDCEEEFF a, b, c, d, x(k + 4), S11, &HF57C0FAFFF d, a, b, c, x(k + 5), S12, &H4787C62AFF c, d, a, b, x(k + 6), S13, &HA8304613FF b, c, d, a, x(k + 7), S14, &HFD469501FF a, b, c, d, x(k + , S11, &H698098D8FF d, a, b, c, x(k + 9), S12, &H8B44F7AFFF c, d, a, b, x(k + 10), S13, &HFFFF5BB1FF b, c, d, a, x(k + 11), S14, &H895CD7BEFF a, b, c, d, x(k + 12), S11, &H6B901122FF d, a, b, c, x(k + 13), S12, &HFD987193FF c, d, a, b, x(k + 14), S13, &HA679438EFF b, c, d, a, x(k + 15), S14, &H49B40821
GG a, b, c, d, x(k + 1), S21, &HF61E2562GG d, a, b, c, x(k + 6), S22, &HC040B340GG c, d, a, b, x(k + 11), S23, &H265E5A51GG b, c, d, a, x(k + 0), S24, &HE9B6C7AAGG a, b, c, d, x(k + 5), S21, &HD62F105DGG d, a, b, c, x(k + 10), S22, &H2441453GG c, d, a, b, x(k + 15), S23, &HD8A1E681GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8GG a, b, c, d, x(k + 9), S21, &H21E1CDE6GG d, a, b, c, x(k + 14), S22, &HC33707D6GG c, d, a, b, x(k + 3), S23, &HF4D50D87GG b, c, d, a, x(k + , S24, &H455A14EDGG a, b, c, d, x(k + 13), S21, &HA9E3E905GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8GG c, d, a, b, x(k + 7), S23, &H676F02D9GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A
HH a, b, c, d, x(k + 5), S31, &HFFFA3942HH d, a, b, c, x(k + , S32, &H8771F681HH c, d, a, b, x(k + 11), S33, &H6D9D6122HH b, c, d, a, x(k + 14), S34, &HFDE5380CHH a, b, c, d, x(k + 1), S31, &HA4BEEA44HH d, a, b, c, x(k + 4), S32, &H4BDECFA9HH c, d, a, b, x(k + 7), S33, &HF6BB4B60HH b, c, d, a, x(k + 10), S34, &HBEBFBC70HH a, b, c, d, x(k + 13), S31, &H289B7EC6HH d, a, b, c, x(k + 0), S32, &HEAA127FAHH c, d, a, b, x(k + 3), S33, &HD4EF3085HH b, c, d, a, x(k + 6), S34, &H4881D05HH a, b, c, d, x(k + 9), S31, &HD9D4D039HH d, a, b, c, x(k + 12), S32, &HE6DB99E5HH c, d, a, b, x(k + 15), S33, &H1FA27CF8HH b, c, d, a, x(k + 2), S34, &HC4AC5665
II a, b, c, d, x(k + 0), S41, &HF4292244II d, a, b, c, x(k + 7), S42, &H432AFF97II c, d, a, b, x(k + 14), S43, &HAB9423A7II b, c, d, a, x(k + 5), S44, &HFC93A039II a, b, c, d, x(k + 12), S41, &H655B59C3II d, a, b, c, x(k + 3), S42, &H8F0CCC92II c, d, a, b, x(k + 10), S43, &HFFEFF47DII b, c, d, a, x(k + 1), S44, &H85845DD1II a, b, c, d, x(k + , S41, &H6FA87E4FII d, a, b, c, x(k + 15), S42, &HFE2CE6E0II c, d, a, b, x(k + 6), S43, &HA3014314II b, c, d, a, x(k + 13), S44, &H4E0811A1II a, b, c, d, x(k + 4), S41, &HF7537E82II d, a, b, c, x(k + 11), S42, &HBD3AF235II c, d, a, b, x(k + 2), S43, &H2AD7D2BBII b, c, d, a, x(k + 9), S44, &HEB86D391
a = AddUnsigned(a, AA)b = AddUnsigned(b, BB)c = AddUnsigned(c, CC)d = AddUnsigned(d, DD)Next
MD5 = LCase(WordToHex(a) & WordToHex(b) & WordToHex(c) & WordToHex(d))End Function%>
seguro.asp
Você está autenticado com o endereço de e-mail:Click aqui para logout.
validar.asp
Secure Login
<%If sSeed = “” ThenResponse.Write “Sua sessão expirou. Você tem esperado por muito tempo, ou seu navegador não suporta cookies.”ElseIf sEmailAddress = “” ThenResponse.Write “Você não introduzir um endereço de e-mail.”ElseIf LCase(sEmailAddress) LCase(sValidEmailAddress) ThenResponse.Write “Você digitou um endereço de e-mail não registrado.”ElseIf sHash = “” And sPassword “” Then
If sPassword sValidPassword ThenResponse.Write “A senha digitada no incorreta. (Inseguro)”ElseResponse.Write “Login feito com sucesso!Click aqui para continuar.Click aqui para logout.”‘ Store credentials in the Session objectSession(“autent”) = “true”Session(“auth_emailaddress”) = sEmailAddressEnd IfElseIf sHash “” ThenIf sHash sValidHash ThenResponse.Write “A senha digitada esta incorreta.”ElseResponse.Write “Login feito com sucesso!Click aqui para continuar.Click aqui para logout.”
Session(“autent”) = “true”Session(“auth_emailaddress”) = sEmailAddressEnd IfElseResponse.Write “Ocorreu um erro.”End If
%>
Voltar
md5.js
function array(n) {for(i=0;i=0) {a=a%0×80000000;a>>=b;a+=0×40000000>>(b-1);} elsea>>=b;return a;}
function shl1(a) {a=a%0×80000000;if (a&0×40000000==0×40000000){a-=0×40000000;a*=2;a+=0×80000000;} elsea*=2;return a;}
function shl(a,b) {a=integer(a);b=integer(b);for (var i=0;i=0)if (t2>=0)return ((t1&t2)+0×80000000);elsereturn (t1&b);elseif (t2>=0)return (a&t2);elsereturn (a&b);}
function or(a,b) {a=integer(a);b=integer(b);var t1=(a-0×80000000);var t2=(b-0×80000000);if (t1>=0)if (t2>=0)return ((t1|t2)+0×80000000);elsereturn ((t1|b)+0×80000000);elseif (t2>=0)return ((a|t2)+0×80000000);elsereturn (a|b);}
function xor(a,b) {a=integer(a);b=integer(b);var t1=(a-0×80000000);var t2=(b-0×80000000);if (t1>=0)if (t2>=0)return (t1^t2);elsereturn ((t1^b)+0×80000000);elseif (t2>=0)return ((a^t2)+0×80000000);elsereturn (a^b);}
function not(a) {a=integer(a);return (0xffffffff-a);}
/* Here begin the real algorithm */
var state = new array(4);var count = new array(2);count[0] = 0;count[1] = 0;var buffer = new array(64);var transformBuffer = new array(16);var digestBits = new array(16);
var S11 = 7;var S12 = 12;var S13 = 17;var S14 = 22;var S21 = 5;var S22 = 9;var S23 = 14;var S24 = 20;var S31 = 4;var S32 = 11;var S33 = 16;var S34 = 23;var S41 = 6;var S42 = 10;var S43 = 15;var S44 = 21;
function F(x,y,z) {return or(and(x,y),and(not(x),z));}
function G(x,y,z) {return or(and(x,z),and(y,not(z)));}
function H(x,y,z) {return xor(xor(x,y),z);}
function I(x,y,z) {return xor(y ,or(x , not(z)));}
function rotateLeft(a,n) {return or(shl(a, n),(shr(a,(32 – n))));}
function FF(a,b,c,d,x,s,ac) {a = a+F(b, c, d) + x + ac;a = rotateLeft(a, s);a = a+b;return a;}
function GG(a,b,c,d,x,s,ac) {a = a+G(b, c, d) +x + ac;a = rotateLeft(a, s);a = a+b;return a;}
function HH(a,b,c,d,x,s,ac) {a = a+H(b, c, d) + x + ac;a = rotateLeft(a, s);a = a+b;return a;}
function II(a,b,c,d,x,s,ac) {a = a+I(b, c, d) + x + ac;a = rotateLeft(a, s);a = a+b;return a;}
function transform(buf,offset) {var a=0, b=0, c=0, d=0;var x = transformBuffer;
a = state[0];b = state[1];c = state[2];d = state[3];
for (i = 0; i < 16; i++) {x[i] = and(buf[i*4+offset],0xff);for (j = 1; j < 4; j++) {x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * ;}}
/* Round 1 */a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */d = GG ( d, a, b, c, x[10], S22, 0×2441453); /* 22 */c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */b = HH ( b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] +=a;state[1] +=b;state[2] +=c;state[3] +=d;
}
function init() {count[0]=count[1] = 0;state[0] = 0×67452301;state[1] = 0xefcdab89;state[2] = 0x98badcfe;state[3] = 0×10325476;for (i = 0; i < digestBits.length; i++)digestBits[i] = 0;}
function update(b) {var index,i;
index = and(shr(count[0],3) , 0x3f);if (count[0]= 63) {transform(buffer, 0);}}
function finish() {var bits = new array(;var padding;var i=0, index=0, padLen=0;
for (i = 0; i < 4; i++) {bits[i] = and(shr(count[0],(i * ), 0xff);}for (i = 0; i < 4; i++) {bits[i+4]=and(shr(count[1],(i * ), 0xff);}index = and(shr(count[0], 3) ,0x3f);padLen = (index < 56) ? (56 – index) : (120 – index);padding = new array(64);padding[0] = 0×80;for (i=0;i<padLen;i++)update(padding[i]);for (i=0;i<8;i++)update(bits[i]);
for (i = 0; i < 4; i++) {for (j = 0; j < 4; j++) {digestBits[i*4+j] = and(shr(state[i], (j * ) , 0xff);}}}
/* End of the MD5 algorithm */
function hexa(n) {var hexa_h = “0123456789abcdef”;var hexa_c=”";var hexa_m=n;for (hexa_i=0;hexa_i<8;hexa_i++) {hexa_c=hexa_h.charAt(Math.abs(hexa_m)%16)+hexa_c;hexa_m=Math.floor(hexa_m/16);}return hexa_c;}
var ascii=”01234567890123456789012345678901″ +” !\”#$%&’()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ”+”[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~”;
function MD5(entree){var l,s,k,ka,kb,kc,kd;
init();for (k=0;k<entree.length;k++) {l=entree.charAt(k);update(ascii.lastIndexOf(l));}finish();ka=kb=kc=kd=0;for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*);for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*);for (i=8;i<12;i++) kc+=shl(digestBits[15-i], ((i-*);for (i=12;i<16;i++) kd+=shl(digestBits[15-i], ((i-12)*);s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);return s;}
Este método pode ser usado para autenticar usuários, permitindo-lhes escrevendo seu endereço de e-mail e senha. Este método usa algoritmo MD5 para enviar a senha criptografada.
Muitos sites usam a autenticação básica com os arquivos. htaccess ou formulários web simples, combinadas com cookies para autenticar seus usuários. Apenas alguns deles usam um servidor HTTPS para enviar os dados.Um usuário mal intensionado pode dar um sniffing de pacotes na rede, e facilmente capturar as senhas, e usá-lo para obter acesso às contas. Vamos criar um “hash” da senha antes de enviá-lo.
Um seed é incluído na página onde o usuário está sendo solicitado para sua senha. Uma cópia seed é armazenada no objeto de sessão no lado do servidor. Quando o usuário envia a página, um javascript calcula o hash MD5 da seed e a senha:
hash = MD5 (senha de sementes)
O endereço de e-mail e o hash são enviados para o servidor. Quando o servidor recebe esses dados, ele lê a senha para o e-mail digitado no banco de dados, e calcula o hash utilizando a seed que é armazenado no objeto Session.
Ambos os hashes são comparados, e se eles são iguais, o usuário está sendo concedido o acesso ao site.
login.asp
<%
If Session(“autent”) = “true” Then
Response.Redirect “seguro.asp”
Response.End
End If
Randomize Timer
Dim sLeft : Dim sRight
sLeft = CStr(Int(Rnd * 99999)) : If Len(sLeft) < 5 Then sLeft = String(5 – Len(sLeft), “0″) & sLeft
sRight = CStr(Int(Rnd * 99999)) : If Len(sRight)
c
<FORM METHOD=”POST” ACTION=”validar.asp” Id=”formLogin” onSubmit=”md5auth(”);”>
Email:
senha:
logoff.asp
Log out
Você está logado agora.
Cliquehere para fazer login.
md5.asp
<%
Private Const BITS_TO_A_BYTE = 8
Private Const BYTES_TO_A_WORD = 4
Private Const BITS_TO_A_WORD = 32
Private m_lOnBits(30)
Private m_l2Power(30)
m_lOnBits(0) = CLng(1)
m_lOnBits(1) = CLng(3)
m_lOnBits(2) = CLng(7)
m_lOnBits(3) = CLng(15)
m_lOnBits(4) = CLng(31)
m_lOnBits(5) = CLng(63)
m_lOnBits(6) = CLng(127)
m_lOnBits(7) = CLng(255)
m_lOnBits( = CLng(511)
m_lOnBits(9) = CLng(1023)
m_lOnBits(10) = CLng(2047)
m_lOnBits(11) = CLng(4095)
m_lOnBits(12) = CLng(8191)
m_lOnBits(13) = CLng(16383)
m_lOnBits(14) = CLng(32767)
m_lOnBits(15) = CLng(65535)
m_lOnBits(16) = CLng(131071)
m_lOnBits(17) = CLng(262143)
m_lOnBits(18) = CLng(524287)
m_lOnBits(19) = CLng(1048575)
m_lOnBits(20) = CLng(2097151)
m_lOnBits(21) = CLng(4194303)
m_lOnBits(22) = CLng(8388607)
m_lOnBits(23) = CLng(16777215)
m_lOnBits(24) = CLng(33554431)
m_lOnBits(25) = CLng(67108863)
m_lOnBits(26) = CLng(134217727)
m_lOnBits(27) = CLng(268435455)
m_lOnBits(28) = CLng(536870911)
m_lOnBits(29) = CLng(1073741823)
m_lOnBits(30) = CLng(2147483647)
m_l2Power(0) = CLng(1)
m_l2Power(1) = CLng(2)
m_l2Power(2) = CLng(4)
m_l2Power(3) = CLng(
m_l2Power(4) = CLng(16)
m_l2Power(5) = CLng(32)
m_l2Power(6) = CLng(64)
m_l2Power(7) = CLng(128)
m_l2Power( = CLng(256)
m_l2Power(9) = CLng(512)
m_l2Power(10) = CLng(1024)
m_l2Power(11) = CLng(2048)
m_l2Power(12) = CLng(4096)
m_l2Power(13) = CLng(8192)
m_l2Power(14) = CLng(16384)
m_l2Power(15) = CLng(32768)
m_l2Power(16) = CLng(65536)
m_l2Power(17) = CLng(131072)
m_l2Power(18) = CLng(262144)
m_l2Power(19) = CLng(524288)
m_l2Power(20) = CLng(1048576)
m_l2Power(21) = CLng(2097152)
m_l2Power(22) = CLng(4194304)
m_l2Power(23) = CLng(8388608)
m_l2Power(24) = CLng(16777216)
m_l2Power(25) = CLng(33554432)
m_l2Power(26) = CLng(67108864)
m_l2Power(27) = CLng(134217728)
m_l2Power(28) = CLng(268435456)
m_l2Power(29) = CLng(536870912)
m_l2Power(30) = CLng(1073741824)
Private Function LShift(lValue, iShiftBits)
If iShiftBits = 0 Then
LShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And 1 Then
LShift = &H80000000
Else
LShift = 0
End If
Exit Function
ElseIf iShiftBits 31 Then
Err.Raise 6
End If
If (lValue And m_l2Power(31 – iShiftBits)) Then
LShift = ((lValue And m_lOnBits(31 – (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000
Else
LShift = ((lValue And m_lOnBits(31 – iShiftBits)) * m_l2Power(iShiftBits))
End If
End Function
Private Function RShift(lValue, iShiftBits)
If iShiftBits = 0 Then
RShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And &H80000000 Then
RShift = 1
Else
RShift = 0
End If
Exit Function
ElseIf iShiftBits 31 Then
Err.Raise 6
End If
RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits)
If (lValue And &H80000000) Then
RShift = (RShift Or (&H40000000 \ m_l2Power(iShiftBits – 1)))
End If
End Function
Private Function RotateLeft(lValue, iShiftBits)
RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 – iShiftBits))
End Function
Private Function AddUnsigned(lX, lY)
Dim lX4
Dim lY4
Dim lX8
Dim lY8
Dim lResult
lX8 = lX And &H80000000
lY8 = lY And &H80000000
lX4 = lX And &H40000000
lY4 = lY And &H40000000
lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)
If lX4 And lY4 Then
lResult = lResult Xor &H80000000 Xor lX8 Xor lY8
ElseIf lX4 Or lY4 Then
If lResult And &H40000000 Then
lResult = lResult Xor &HC0000000 Xor lX8 Xor lY8
Else
lResult = lResult Xor &H40000000 Xor lX8 Xor lY8
End If
Else
lResult = lResult Xor lX8 Xor lY8
End If
AddUnsigned = lResult
End Function
Private Function F(x, y, z)
F = (x And y) Or ((Not x) And z)
End Function
Private Function G(x, y, z)
G = (x And z) Or (y And (Not z))
End Function
Private Function H(x, y, z)
H = (x Xor y Xor z)
End Function
Private Function I(x, y, z)
I = (y Xor (x Or (Not z)))
End Function
Private Sub FF(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub GG(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub HH(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub II(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Function ConvertToWordArray(sMessage)
Dim lMessageLength
Dim lNumberOfWords
Dim lWordArray()
Dim lBytePosition
Dim lByteCount
Dim lWordCount
Const MODULUS_BITS = 512
Const CONGRUENT_BITS = 448
lMessageLength = Len(sMessage)
lNumberOfWords = (((lMessageLength + ((MODULUS_BITS – CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD)
ReDim lWordArray(lNumberOfWords – 1)
lBytePosition = 0
lByteCount = 0
Do Until lByteCount >= lMessageLength
lWordCount = lByteCount \ BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)
lByteCount = lByteCount + 1
Loop
lWordCount = lByteCount \ BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(&H80, lBytePosition)
lWordArray(lNumberOfWords – 2) = LShift(lMessageLength, 3)
lWordArray(lNumberOfWords – 1) = RShift(lMessageLength, 29)
ConvertToWordArray = lWordArray
End Function
Private Function WordToHex(lValue)
Dim lByte
Dim lCount
For lCount = 0 To 3
lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE – 1)
WordToHex = WordToHex & Right(“0″ & Hex(lByte), 2)
Next
End Function
Public Function MD5(sMessage)
Dim x
Dim k
Dim AA
Dim BB
Dim CC
Dim DD
Dim a
Dim b
Dim c
Dim d
Const S11 = 7
Const S12 = 12
Const S13 = 17
Const S14 = 22
Const S21 = 5
Const S22 = 9
Const S23 = 14
Const S24 = 20
Const S31 = 4
Const S32 = 11
Const S33 = 16
Const S34 = 23
Const S41 = 6
Const S42 = 10
Const S43 = 15
Const S44 = 21
x = ConvertToWordArray(sMessage)
a = &H67452301
b = &HEFCDAB89
c = &H98BADCFE
d = &H10325476
For k = 0 To UBound(x) Step 16
AA = a
BB = b
CC = c
DD = d
FF a, b, c, d, x(k + 0), S11, &HD76AA478
FF d, a, b, c, x(k + 1), S12, &HE8C7B756
FF c, d, a, b, x(k + 2), S13, &H242070DB
FF b, c, d, a, x(k + 3), S14, &HC1BDCEEE
FF a, b, c, d, x(k + 4), S11, &HF57C0FAF
FF d, a, b, c, x(k + 5), S12, &H4787C62A
FF c, d, a, b, x(k + 6), S13, &HA8304613
FF b, c, d, a, x(k + 7), S14, &HFD469501
FF a, b, c, d, x(k + , S11, &H698098D8
FF d, a, b, c, x(k + 9), S12, &H8B44F7AF
FF c, d, a, b, x(k + 10), S13, &HFFFF5BB1
FF b, c, d, a, x(k + 11), S14, &H895CD7BE
FF a, b, c, d, x(k + 12), S11, &H6B901122
FF d, a, b, c, x(k + 13), S12, &HFD987193
FF c, d, a, b, x(k + 14), S13, &HA679438E
FF b, c, d, a, x(k + 15), S14, &H49B40821
GG a, b, c, d, x(k + 1), S21, &HF61E2562
GG d, a, b, c, x(k + 6), S22, &HC040B340
GG c, d, a, b, x(k + 11), S23, &H265E5A51
GG b, c, d, a, x(k + 0), S24, &HE9B6C7AA
GG a, b, c, d, x(k + 5), S21, &HD62F105D
GG d, a, b, c, x(k + 10), S22, &H2441453
GG c, d, a, b, x(k + 15), S23, &HD8A1E681
GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8
GG a, b, c, d, x(k + 9), S21, &H21E1CDE6
GG d, a, b, c, x(k + 14), S22, &HC33707D6
GG c, d, a, b, x(k + 3), S23, &HF4D50D87
GG b, c, d, a, x(k + , S24, &H455A14ED
GG a, b, c, d, x(k + 13), S21, &HA9E3E905
GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8
GG c, d, a, b, x(k + 7), S23, &H676F02D9
GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A
HH a, b, c, d, x(k + 5), S31, &HFFFA3942
HH d, a, b, c, x(k + , S32, &H8771F681
HH c, d, a, b, x(k + 11), S33, &H6D9D6122
HH b, c, d, a, x(k + 14), S34, &HFDE5380C
HH a, b, c, d, x(k + 1), S31, &HA4BEEA44
HH d, a, b, c, x(k + 4), S32, &H4BDECFA9
HH c, d, a, b, x(k + 7), S33, &HF6BB4B60
HH b, c, d, a, x(k + 10), S34, &HBEBFBC70
HH a, b, c, d, x(k + 13), S31, &H289B7EC6
HH d, a, b, c, x(k + 0), S32, &HEAA127FA
HH c, d, a, b, x(k + 3), S33, &HD4EF3085
HH b, c, d, a, x(k + 6), S34, &H4881D05
HH a, b, c, d, x(k + 9), S31, &HD9D4D039
HH d, a, b, c, x(k + 12), S32, &HE6DB99E5
HH c, d, a, b, x(k + 15), S33, &H1FA27CF8
HH b, c, d, a, x(k + 2), S34, &HC4AC5665
II a, b, c, d, x(k + 0), S41, &HF4292244
II d, a, b, c, x(k + 7), S42, &H432AFF97
II c, d, a, b, x(k + 14), S43, &HAB9423A7
II b, c, d, a, x(k + 5), S44, &HFC93A039
II a, b, c, d, x(k + 12), S41, &H655B59C3
II d, a, b, c, x(k + 3), S42, &H8F0CCC92
II c, d, a, b, x(k + 10), S43, &HFFEFF47D
II b, c, d, a, x(k + 1), S44, &H85845DD1
II a, b, c, d, x(k + , S41, &H6FA87E4F
II d, a, b, c, x(k + 15), S42, &HFE2CE6E0
II c, d, a, b, x(k + 6), S43, &HA3014314
II b, c, d, a, x(k + 13), S44, &H4E0811A1
II a, b, c, d, x(k + 4), S41, &HF7537E82
II d, a, b, c, x(k + 11), S42, &HBD3AF235
II c, d, a, b, x(k + 2), S43, &H2AD7D2BB
II b, c, d, a, x(k + 9), S44, &HEB86D391
a = AddUnsigned(a, AA)
b = AddUnsigned(b, BB)
c = AddUnsigned(c, CC)
d = AddUnsigned(d, DD)
Next
MD5 = LCase(WordToHex(a) & WordToHex(b) & WordToHex(c) & WordToHex(d))
End Function
%>
seguro.asp
Você está autenticado com o endereço de e-mail:
Click aqui para logout.
validar.asp
Secure Login
<%
If sSeed = “” Then
Response.Write “Sua sessão expirou. Você tem esperado por muito tempo, ou seu navegador não suporta cookies.”
ElseIf sEmailAddress = “” Then
Response.Write “Você não introduzir um endereço de e-mail.”
ElseIf LCase(sEmailAddress) LCase(sValidEmailAddress) Then
Response.Write “Você digitou um endereço de e-mail não registrado.”
ElseIf sHash = “” And sPassword “” Then
If sPassword sValidPassword Then
Response.Write “A senha digitada no incorreta. (Inseguro)”
Else
Response.Write “Login feito com sucesso!
Click aqui para continuar.
Click aqui para logout.”
‘ Store credentials in the Session object
Session(“autent”) = “true”
Session(“auth_emailaddress”) = sEmailAddress
End If
ElseIf sHash “” Then
If sHash sValidHash Then
Response.Write “A senha digitada esta incorreta.”
Else
Response.Write “Login feito com sucesso!
Click aqui para continuar.
Click aqui para logout.”
Session(“autent”) = “true”
Session(“auth_emailaddress”) = sEmailAddress
End If
Else
Response.Write “Ocorreu um erro.”
End If
%>
Voltar
md5.js
function array(n) {
for(i=0;i=0) {
a=a%0×80000000;
a>>=b;
a+=0×40000000>>(b-1);
} else
a>>=b;
return a;
}
function shl1(a) {
a=a%0×80000000;
if (a&0×40000000==0×40000000)
{
a-=0×40000000;
a*=2;
a+=0×80000000;
} else
a*=2;
return a;
}
function shl(a,b) {
a=integer(a);
b=integer(b);
for (var i=0;i=0)
if (t2>=0)
return ((t1&t2)+0×80000000);
else
return (t1&b);
else
if (t2>=0)
return (a&t2);
else
return (a&b);
}
function or(a,b) {
a=integer(a);
b=integer(b);
var t1=(a-0×80000000);
var t2=(b-0×80000000);
if (t1>=0)
if (t2>=0)
return ((t1|t2)+0×80000000);
else
return ((t1|b)+0×80000000);
else
if (t2>=0)
return ((a|t2)+0×80000000);
else
return (a|b);
}
function xor(a,b) {
a=integer(a);
b=integer(b);
var t1=(a-0×80000000);
var t2=(b-0×80000000);
if (t1>=0)
if (t2>=0)
return (t1^t2);
else
return ((t1^b)+0×80000000);
else
if (t2>=0)
return ((a^t2)+0×80000000);
else
return (a^b);
}
function not(a) {
a=integer(a);
return (0xffffffff-a);
}
/* Here begin the real algorithm */
var state = new array(4);
var count = new array(2);
count[0] = 0;
count[1] = 0;
var buffer = new array(64);
var transformBuffer = new array(16);
var digestBits = new array(16);
var S11 = 7;
var S12 = 12;
var S13 = 17;
var S14 = 22;
var S21 = 5;
var S22 = 9;
var S23 = 14;
var S24 = 20;
var S31 = 4;
var S32 = 11;
var S33 = 16;
var S34 = 23;
var S41 = 6;
var S42 = 10;
var S43 = 15;
var S44 = 21;
function F(x,y,z) {
return or(and(x,y),and(not(x),z));
}
function G(x,y,z) {
return or(and(x,z),and(y,not(z)));
}
function H(x,y,z) {
return xor(xor(x,y),z);
}
function I(x,y,z) {
return xor(y ,or(x , not(z)));
}
function rotateLeft(a,n) {
return or(shl(a, n),(shr(a,(32 – n))));
}
function FF(a,b,c,d,x,s,ac) {
a = a+F(b, c, d) + x + ac;
a = rotateLeft(a, s);
a = a+b;
return a;
}
function GG(a,b,c,d,x,s,ac) {
a = a+G(b, c, d) +x + ac;
a = rotateLeft(a, s);
a = a+b;
return a;
}
function HH(a,b,c,d,x,s,ac) {
a = a+H(b, c, d) + x + ac;
a = rotateLeft(a, s);
a = a+b;
return a;
}
function II(a,b,c,d,x,s,ac) {
a = a+I(b, c, d) + x + ac;
a = rotateLeft(a, s);
a = a+b;
return a;
}
function transform(buf,offset) {
var a=0, b=0, c=0, d=0;
var x = transformBuffer;
a = state[0];
b = state[1];
c = state[2];
d = state[3];
for (i = 0; i < 16; i++) {
x[i] = and(buf[i*4+offset],0xff);
for (j = 1; j < 4; j++) {
x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * ;
}
}
/* Round 1 */
a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
d = GG ( d, a, b, c, x[10], S22, 0×2441453); /* 22 */
c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
b = HH ( b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] +=a;
state[1] +=b;
state[2] +=c;
state[3] +=d;
}
function init() {
count[0]=count[1] = 0;
state[0] = 0×67452301;
state[1] = 0xefcdab89;
state[2] = 0x98badcfe;
state[3] = 0×10325476;
for (i = 0; i < digestBits.length; i++)
digestBits[i] = 0;
}
function update(b) {
var index,i;
index = and(shr(count[0],3) , 0x3f);
if (count[0]= 63) {
transform(buffer, 0);
}
}
function finish() {
var bits = new array(;
var padding;
var i=0, index=0, padLen=0;
for (i = 0; i < 4; i++) {
bits[i] = and(shr(count[0],(i * ), 0xff);
}
for (i = 0; i < 4; i++) {
bits[i+4]=and(shr(count[1],(i * ), 0xff);
}
index = and(shr(count[0], 3) ,0x3f);
padLen = (index < 56) ? (56 – index) : (120 – index);
padding = new array(64);
padding[0] = 0×80;
for (i=0;i<padLen;i++)
update(padding[i]);
for (i=0;i<8;i++)
update(bits[i]);
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
digestBits[i*4+j] = and(shr(state[i], (j * ) , 0xff);
}
}
}
/* End of the MD5 algorithm */
function hexa(n) {
var hexa_h = “0123456789abcdef”;
var hexa_c=”";
var hexa_m=n;
for (hexa_i=0;hexa_i<8;hexa_i++) {
hexa_c=hexa_h.charAt(Math.abs(hexa_m)%16)+hexa_c;
hexa_m=Math.floor(hexa_m/16);
}
return hexa_c;
}
var ascii=”01234567890123456789012345678901″ +
” !\”#$%&’()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ”+
“[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~”;
function MD5(entree)
{
var l,s,k,ka,kb,kc,kd;
init();
for (k=0;k<entree.length;k++) {
l=entree.charAt(k);
update(ascii.lastIndexOf(l));
}
finish();
ka=kb=kc=kd=0;
for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*);
for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*);
for (i=8;i<12;i++) kc+=shl(digestBits[15-i], ((i-*);
for (i=12;i<16;i++) kd+=shl(digestBits[15-i], ((i-12)*);
s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);
return s;
}
Autenticação de Usuário
Este método pode ser usado para autenticar usuários, permitindo-lhes escrevendo seu endereço de e-mail e senha. Este método usa algoritmo MD5 para enviar a senha criptografada.
Muitos sites usam a autenticação básica com os arquivos. htaccess ou formulários web simples, combinadas com cookies para autenticar seus usuários. Apenas alguns deles usam um servidor HTTPS para enviar os dados.Um usuário mal intensionado pode dar um sniffing de pacotes na rede, e facilmente capturar as senhas, e usá-lo para obter acesso às contas. Vamos criar um “hash” da senha antes de enviá-lo.
Um seed é incluído na página onde o usuário está sendo solicitado para sua senha. Uma cópia seed é armazenada no objeto de sessão no lado do servidor. Quando o usuário envia a página, um javascript calcula o hash MD5 da seed e a senha:
hash = MD5 (senha de sementes)
O endereço de e-mail e o hash são enviados para o servidor. Quando o servidor recebe esses dados, ele lê a senha para o e-mail digitado no banco de dados, e calcula o hash utilizando a seed que é armazenado no objeto Session.Ambos os hashes são comparados, e se eles são iguais, o usuário está sendo concedido o acesso ao site.
login.asp
<%
If Session(“autent”) = “true” ThenResponse.Redirect “seguro.asp”Response.EndEnd If
Randomize Timer
Dim sLeft : Dim sRightsLeft = CStr(Int(Rnd * 99999)) : If Len(sLeft) < 5 Then sLeft = String(5 – Len(sLeft), “0″) & sLeftsRight = CStr(Int(Rnd * 99999)) : If Len(sRight)c
<FORM METHOD=”POST” ACTION=”validar.asp” Id=”formLogin” onSubmit=”md5auth(”);”>
Email: senha: logoff.asp
Log out
Você está logado agora.Cliquehere para fazer login.
md5.asp
<%
Private Const BITS_TO_A_BYTE = 8Private Const BYTES_TO_A_WORD = 4Private Const BITS_TO_A_WORD = 32
Private m_lOnBits(30)Private m_l2Power(30)
m_lOnBits(0) = CLng(1)m_lOnBits(1) = CLng(3)m_lOnBits(2) = CLng(7)m_lOnBits(3) = CLng(15)m_lOnBits(4) = CLng(31)m_lOnBits(5) = CLng(63)m_lOnBits(6) = CLng(127)m_lOnBits(7) = CLng(255)m_lOnBits( = CLng(511)m_lOnBits(9) = CLng(1023)m_lOnBits(10) = CLng(2047)m_lOnBits(11) = CLng(4095)m_lOnBits(12) = CLng(8191)m_lOnBits(13) = CLng(16383)m_lOnBits(14) = CLng(32767)m_lOnBits(15) = CLng(65535)m_lOnBits(16) = CLng(131071)m_lOnBits(17) = CLng(262143)m_lOnBits(18) = CLng(524287)m_lOnBits(19) = CLng(1048575)m_lOnBits(20) = CLng(2097151)m_lOnBits(21) = CLng(4194303)m_lOnBits(22) = CLng(8388607)m_lOnBits(23) = CLng(16777215)m_lOnBits(24) = CLng(33554431)m_lOnBits(25) = CLng(67108863)m_lOnBits(26) = CLng(134217727)m_lOnBits(27) = CLng(268435455)m_lOnBits(28) = CLng(536870911)m_lOnBits(29) = CLng(1073741823)m_lOnBits(30) = CLng(2147483647)
m_l2Power(0) = CLng(1)m_l2Power(1) = CLng(2)m_l2Power(2) = CLng(4)m_l2Power(3) = CLng(8)m_l2Power(4) = CLng(16)m_l2Power(5) = CLng(32)m_l2Power(6) = CLng(64)m_l2Power(7) = CLng(128)m_l2Power( = CLng(256)m_l2Power(9) = CLng(512)m_l2Power(10) = CLng(1024)m_l2Power(11) = CLng(2048)m_l2Power(12) = CLng(4096)m_l2Power(13) = CLng(8192)m_l2Power(14) = CLng(16384)m_l2Power(15) = CLng(32768)m_l2Power(16) = CLng(65536)m_l2Power(17) = CLng(131072)m_l2Power(18) = CLng(262144)m_l2Power(19) = CLng(524288)m_l2Power(20) = CLng(1048576)m_l2Power(21) = CLng(2097152)m_l2Power(22) = CLng(4194304)m_l2Power(23) = CLng(8388608)m_l2Power(24) = CLng(16777216)m_l2Power(25) = CLng(33554432)m_l2Power(26) = CLng(67108864)m_l2Power(27) = CLng(134217728)m_l2Power(28) = CLng(268435456)m_l2Power(29) = CLng(536870912)m_l2Power(30) = CLng(1073741824)
Private Function LShift(lValue, iShiftBits)If iShiftBits = 0 ThenLShift = lValueExit FunctionElseIf iShiftBits = 31 ThenIf lValue And 1 ThenLShift = &H80000000ElseLShift = 0End IfExit FunctionElseIf iShiftBits 31 ThenErr.Raise 6End If
If (lValue And m_l2Power(31 – iShiftBits)) ThenLShift = ((lValue And m_lOnBits(31 – (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000ElseLShift = ((lValue And m_lOnBits(31 – iShiftBits)) * m_l2Power(iShiftBits))End IfEnd Function
Private Function RShift(lValue, iShiftBits)If iShiftBits = 0 ThenRShift = lValueExit FunctionElseIf iShiftBits = 31 ThenIf lValue And &H80000000 ThenRShift = 1ElseRShift = 0End IfExit FunctionElseIf iShiftBits 31 ThenErr.Raise 6End If
RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits)
If (lValue And &H80000000) ThenRShift = (RShift Or (&H40000000 \ m_l2Power(iShiftBits – 1)))End IfEnd Function
Private Function RotateLeft(lValue, iShiftBits)RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 – iShiftBits))End Function
Private Function AddUnsigned(lX, lY)Dim lX4Dim lY4Dim lX8Dim lY8Dim lResult
lX8 = lX And &H80000000lY8 = lY And &H80000000lX4 = lX And &H40000000lY4 = lY And &H40000000
lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)
If lX4 And lY4 ThenlResult = lResult Xor &H80000000 Xor lX8 Xor lY8ElseIf lX4 Or lY4 ThenIf lResult And &H40000000 ThenlResult = lResult Xor &HC0000000 Xor lX8 Xor lY8ElselResult = lResult Xor &H40000000 Xor lX8 Xor lY8End IfElselResult = lResult Xor lX8 Xor lY8End If
AddUnsigned = lResultEnd Function
Private Function F(x, y, z)F = (x And y) Or ((Not x) And z)End Function
Private Function G(x, y, z)G = (x And z) Or (y And (Not z))End Function
Private Function H(x, y, z)H = (x Xor y Xor z)End Function
Private Function I(x, y, z)I = (y Xor (x Or (Not z)))End Function
Private Sub FF(a, b, c, d, x, s, ac)a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac))a = RotateLeft(a, s)a = AddUnsigned(a, b)End Sub
Private Sub GG(a, b, c, d, x, s, ac)a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac))a = RotateLeft(a, s)a = AddUnsigned(a, b)End Sub
Private Sub HH(a, b, c, d, x, s, ac)a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac))a = RotateLeft(a, s)a = AddUnsigned(a, b)End Sub
Private Sub II(a, b, c, d, x, s, ac)a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac))a = RotateLeft(a, s)a = AddUnsigned(a, b)End Sub
Private Function ConvertToWordArray(sMessage)Dim lMessageLengthDim lNumberOfWordsDim lWordArray()Dim lBytePositionDim lByteCountDim lWordCount
Const MODULUS_BITS = 512Const CONGRUENT_BITS = 448
lMessageLength = Len(sMessage)
lNumberOfWords = (((lMessageLength + ((MODULUS_BITS – CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD)ReDim lWordArray(lNumberOfWords – 1)
lBytePosition = 0lByteCount = 0Do Until lByteCount >= lMessageLengthlWordCount = lByteCount \ BYTES_TO_A_WORDlBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTElWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)lByteCount = lByteCount + 1Loop
lWordCount = lByteCount \ BYTES_TO_A_WORDlBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(&H80, lBytePosition)
lWordArray(lNumberOfWords – 2) = LShift(lMessageLength, 3)lWordArray(lNumberOfWords – 1) = RShift(lMessageLength, 29)
ConvertToWordArray = lWordArrayEnd Function
Private Function WordToHex(lValue)Dim lByteDim lCount
For lCount = 0 To 3lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE – 1)WordToHex = WordToHex & Right(“0″ & Hex(lByte), 2)NextEnd Function
Public Function MD5(sMessage)Dim xDim kDim AADim BBDim CCDim DDDim aDim bDim cDim d
Const S11 = 7Const S12 = 12Const S13 = 17Const S14 = 22Const S21 = 5Const S22 = 9Const S23 = 14Const S24 = 20Const S31 = 4Const S32 = 11Const S33 = 16Const S34 = 23Const S41 = 6Const S42 = 10Const S43 = 15Const S44 = 21
x = ConvertToWordArray(sMessage)
a = &H67452301b = &HEFCDAB89c = &H98BADCFEd = &H10325476
For k = 0 To UBound(x) Step 16AA = aBB = bCC = cDD = d
FF a, b, c, d, x(k + 0), S11, &HD76AA478FF d, a, b, c, x(k + 1), S12, &HE8C7B756FF c, d, a, b, x(k + 2), S13, &H242070DBFF b, c, d, a, x(k + 3), S14, &HC1BDCEEEFF a, b, c, d, x(k + 4), S11, &HF57C0FAFFF d, a, b, c, x(k + 5), S12, &H4787C62AFF c, d, a, b, x(k + 6), S13, &HA8304613FF b, c, d, a, x(k + 7), S14, &HFD469501FF a, b, c, d, x(k + , S11, &H698098D8FF d, a, b, c, x(k + 9), S12, &H8B44F7AFFF c, d, a, b, x(k + 10), S13, &HFFFF5BB1FF b, c, d, a, x(k + 11), S14, &H895CD7BEFF a, b, c, d, x(k + 12), S11, &H6B901122FF d, a, b, c, x(k + 13), S12, &HFD987193FF c, d, a, b, x(k + 14), S13, &HA679438EFF b, c, d, a, x(k + 15), S14, &H49B40821
GG a, b, c, d, x(k + 1), S21, &HF61E2562GG d, a, b, c, x(k + 6), S22, &HC040B340GG c, d, a, b, x(k + 11), S23, &H265E5A51GG b, c, d, a, x(k + 0), S24, &HE9B6C7AAGG a, b, c, d, x(k + 5), S21, &HD62F105DGG d, a, b, c, x(k + 10), S22, &H2441453GG c, d, a, b, x(k + 15), S23, &HD8A1E681GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8GG a, b, c, d, x(k + 9), S21, &H21E1CDE6GG d, a, b, c, x(k + 14), S22, &HC33707D6GG c, d, a, b, x(k + 3), S23, &HF4D50D87GG b, c, d, a, x(k + , S24, &H455A14EDGG a, b, c, d, x(k + 13), S21, &HA9E3E905GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8GG c, d, a, b, x(k + 7), S23, &H676F02D9GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A
HH a, b, c, d, x(k + 5), S31, &HFFFA3942HH d, a, b, c, x(k + , S32, &H8771F681HH c, d, a, b, x(k + 11), S33, &H6D9D6122HH b, c, d, a, x(k + 14), S34, &HFDE5380CHH a, b, c, d, x(k + 1), S31, &HA4BEEA44HH d, a, b, c, x(k + 4), S32, &H4BDECFA9HH c, d, a, b, x(k + 7), S33, &HF6BB4B60HH b, c, d, a, x(k + 10), S34, &HBEBFBC70HH a, b, c, d, x(k + 13), S31, &H289B7EC6HH d, a, b, c, x(k + 0), S32, &HEAA127FAHH c, d, a, b, x(k + 3), S33, &HD4EF3085HH b, c, d, a, x(k + 6), S34, &H4881D05HH a, b, c, d, x(k + 9), S31, &HD9D4D039HH d, a, b, c, x(k + 12), S32, &HE6DB99E5HH c, d, a, b, x(k + 15), S33, &H1FA27CF8HH b, c, d, a, x(k + 2), S34, &HC4AC5665
II a, b, c, d, x(k + 0), S41, &HF4292244II d, a, b, c, x(k + 7), S42, &H432AFF97II c, d, a, b, x(k + 14), S43, &HAB9423A7II b, c, d, a, x(k + 5), S44, &HFC93A039II a, b, c, d, x(k + 12), S41, &H655B59C3II d, a, b, c, x(k + 3), S42, &H8F0CCC92II c, d, a, b, x(k + 10), S43, &HFFEFF47DII b, c, d, a, x(k + 1), S44, &H85845DD1II a, b, c, d, x(k + , S41, &H6FA87E4FII d, a, b, c, x(k + 15), S42, &HFE2CE6E0II c, d, a, b, x(k + 6), S43, &HA3014314II b, c, d, a, x(k + 13), S44, &H4E0811A1II a, b, c, d, x(k + 4), S41, &HF7537E82II d, a, b, c, x(k + 11), S42, &HBD3AF235II c, d, a, b, x(k + 2), S43, &H2AD7D2BBII b, c, d, a, x(k + 9), S44, &HEB86D391
a = AddUnsigned(a, AA)b = AddUnsigned(b, BB)c = AddUnsigned(c, CC)d = AddUnsigned(d, DD)Next
MD5 = LCase(WordToHex(a) & WordToHex(b) & WordToHex(c) & WordToHex(d))End Function%>
seguro.asp
Você está autenticado com o endereço de e-mail:Click aqui para logout.
validar.asp
Secure Login
<%If sSeed = “” ThenResponse.Write “Sua sessão expirou. Você tem esperado por muito tempo, ou seu navegador não suporta cookies.”ElseIf sEmailAddress = “” ThenResponse.Write “Você não introduzir um endereço de e-mail.”ElseIf LCase(sEmailAddress) LCase(sValidEmailAddress) ThenResponse.Write “Você digitou um endereço de e-mail não registrado.”ElseIf sHash = “” And sPassword “” Then
If sPassword sValidPassword ThenResponse.Write “A senha digitada no incorreta. (Inseguro)”ElseResponse.Write “Login feito com sucesso!Click aqui para continuar.Click aqui para logout.”‘ Store credentials in the Session objectSession(“autent”) = “true”Session(“auth_emailaddress”) = sEmailAddressEnd IfElseIf sHash “” ThenIf sHash sValidHash ThenResponse.Write “A senha digitada esta incorreta.”ElseResponse.Write “Login feito com sucesso!Click aqui para continuar.Click aqui para logout.”
Session(“autent”) = “true”Session(“auth_emailaddress”) = sEmailAddressEnd IfElseResponse.Write “Ocorreu um erro.”End If
%>
Voltar
md5.js
function array(n) {for(i=0;i=0) {a=a%0×80000000;a>>=b;a+=0×40000000>>(b-1);} elsea>>=b;return a;}
function shl1(a) {a=a%0×80000000;if (a&0×40000000==0×40000000){a-=0×40000000;a*=2;a+=0×80000000;} elsea*=2;return a;}
function shl(a,b) {a=integer(a);b=integer(b);for (var i=0;i=0)if (t2>=0)return ((t1&t2)+0×80000000);elsereturn (t1&b);elseif (t2>=0)return (a&t2);elsereturn (a&b);}
function or(a,b) {a=integer(a);b=integer(b);var t1=(a-0×80000000);var t2=(b-0×80000000);if (t1>=0)if (t2>=0)return ((t1|t2)+0×80000000);elsereturn ((t1|b)+0×80000000);elseif (t2>=0)return ((a|t2)+0×80000000);elsereturn (a|b);}
function xor(a,b) {a=integer(a);b=integer(b);var t1=(a-0×80000000);var t2=(b-0×80000000);if (t1>=0)if (t2>=0)return (t1^t2);elsereturn ((t1^b)+0×80000000);elseif (t2>=0)return ((a^t2)+0×80000000);elsereturn (a^b);}
function not(a) {a=integer(a);return (0xffffffff-a);}
/* Here begin the real algorithm */
var state = new array(4);var count = new array(2);count[0] = 0;count[1] = 0;var buffer = new array(64);var transformBuffer = new array(16);var digestBits = new array(16);
var S11 = 7;var S12 = 12;var S13 = 17;var S14 = 22;var S21 = 5;var S22 = 9;var S23 = 14;var S24 = 20;var S31 = 4;var S32 = 11;var S33 = 16;var S34 = 23;var S41 = 6;var S42 = 10;var S43 = 15;var S44 = 21;
function F(x,y,z) {return or(and(x,y),and(not(x),z));}
function G(x,y,z) {return or(and(x,z),and(y,not(z)));}
function H(x,y,z) {return xor(xor(x,y),z);}
function I(x,y,z) {return xor(y ,or(x , not(z)));}
function rotateLeft(a,n) {return or(shl(a, n),(shr(a,(32 – n))));}
function FF(a,b,c,d,x,s,ac) {a = a+F(b, c, d) + x + ac;a = rotateLeft(a, s);a = a+b;return a;}
function GG(a,b,c,d,x,s,ac) {a = a+G(b, c, d) +x + ac;a = rotateLeft(a, s);a = a+b;return a;}
function HH(a,b,c,d,x,s,ac) {a = a+H(b, c, d) + x + ac;a = rotateLeft(a, s);a = a+b;return a;}
function II(a,b,c,d,x,s,ac) {a = a+I(b, c, d) + x + ac;a = rotateLeft(a, s);a = a+b;return a;}
function transform(buf,offset) {var a=0, b=0, c=0, d=0;var x = transformBuffer;
a = state[0];b = state[1];c = state[2];d = state[3];
for (i = 0; i < 16; i++) {x[i] = and(buf[i*4+offset],0xff);for (j = 1; j < 4; j++) {x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * ;}}
/* Round 1 */a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */d = GG ( d, a, b, c, x[10], S22, 0×2441453); /* 22 */c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */b = HH ( b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] +=a;state[1] +=b;state[2] +=c;state[3] +=d;
}
function init() {count[0]=count[1] = 0;state[0] = 0×67452301;state[1] = 0xefcdab89;state[2] = 0x98badcfe;state[3] = 0×10325476;for (i = 0; i < digestBits.length; i++)digestBits[i] = 0;}
function update(b) {var index,i;
index = and(shr(count[0],3) , 0x3f);if (count[0]= 63) {transform(buffer, 0);}}
function finish() {var bits = new array(;var padding;var i=0, index=0, padLen=0;
for (i = 0; i < 4; i++) {bits[i] = and(shr(count[0],(i * ), 0xff);}for (i = 0; i < 4; i++) {bits[i+4]=and(shr(count[1],(i * ), 0xff);}index = and(shr(count[0], 3) ,0x3f);padLen = (index < 56) ? (56 – index) : (120 – index);padding = new array(64);padding[0] = 0×80;for (i=0;i<padLen;i++)update(padding[i]);for (i=0;i<8;i++)update(bits[i]);
for (i = 0; i < 4; i++) {for (j = 0; j < 4; j++) {digestBits[i*4+j] = and(shr(state[i], (j * ) , 0xff);}}}
/* End of the MD5 algorithm */
function hexa(n) {var hexa_h = “0123456789abcdef”;var hexa_c=”";var hexa_m=n;for (hexa_i=0;hexa_i<8;hexa_i++) {hexa_c=hexa_h.charAt(Math.abs(hexa_m)%16)+hexa_c;hexa_m=Math.floor(hexa_m/16);}return hexa_c;}
var ascii=”01234567890123456789012345678901″ +” !\”#$%&’()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ”+”[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~”;
function MD5(entree){var l,s,k,ka,kb,kc,kd;
init();for (k=0;k<entree.length;k++) {l=entree.charAt(k);update(ascii.lastIndexOf(l));}finish();ka=kb=kc=kd=0;for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*);for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*);for (i=8;i<12;i++) kc+=shl(digestBits[15-i], ((i-*);for (i=12;i<16;i++) kd+=shl(digestBits[15-i], ((i-12)*);s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);return s;}
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos
Qua 16 Nov - 16:14 por fernandosena
» Segurança e redes sem fio
Qua 16 Nov - 16:11 por fernandosena
» Nokia lançará tablet com Windows 8 em junho de 2012, diz executivo
Qua 16 Nov - 16:05 por fernandosena
» Empresa registra aumento de 472% no número de vírus para Android
Qua 16 Nov - 16:03 por fernandosena
» YouTube investe US$ 100 milhões em vídeos
Sex 7 Out - 8:34 por fernandosena
» Todos os títulos futuros da Microsoft devem trazer suporte para o Kinect
Sex 7 Out - 8:25 por fernandosena
» Resident Evil 5 - PC
Sex 7 Out - 8:22 por fernandosena
» Novo trailer de Assassin’s Creed Revelations é lançado
Sex 7 Out - 8:12 por fernandosena
» Biostar apresenta nova placa-mãe que permite acesso remoto via smartphones
Sex 7 Out - 8:08 por fernandosena