Una idea es: ingrese un lote de códigos ganadores únicos en la base de datos. Cuando gane, saque uno, haga una marca y le indique el código ganador. Felicitaciones, su código ganador es (recuerde cuando lo reciba). el premio Requerido): XXXXX
Luego, el usuario ingresa XXXXXXXXXXXXXXX y puede reclamar el premio luego de una simple verificación.
¿Ha utilizado alguna vez una función de este tipo o alguna vez ha querido desarrollar una?
Una idea es: ingrese un lote de códigos ganadores únicos en la base de datos. Cuando gane, saque uno, haga una marca y diga el código ganador.
usuario.
Pero esto requiere ingresar primero un lote de códigos ganadores en la base de datos. ¿Existe algún otro método?
Por ejemplo: 200807151054281502895e585d7e4b529e, ¿es posible confirmar el premio sin consultar la base de datos para su verificación?
¿El código es válido (no falsificado)?
Tengo una idea, si estás dispuesto, escúchame :)
Por ejemplo, este código ganador: 200807151054281502895e585d7e4b529e
Consta de tres partes
20080715105428 1502 895e585d7e4b529e
20080715105428 es año, mes, día, hora, minuto y segundo AAAAMMDDhhmmss
1502 es un número aleatorio de cuatro dígitos para evitar la duplicación de la primera parte.
895e585d7e4b529e Las dos primeras partes + el valor MD5 de 16 bits de PrivateKey
En una palabra: los primeros 18 dígitos y los últimos 16 dígitos del código ganador están relacionados.
De esta manera, mientras otros no puedan adivinar su clave privada, no podrán falsificar su código ganador.
La desventaja es que el código ganador es un poco largo: (
El código es el siguiente:
getkey() devuelve un código ganador único
ckkey(s) verifica si el código ganador tiene premio
Copie el código de código de la siguiente manera:
<%
Constante privada BITS_TO_A_BYTE = 8
Const privado BYTES_TO_A_WORD = 4
Const privada BITS_TO_A_WORD = 32
Privado m_lOnBits(30)
Privado m_l2Power(30)
Función privada LShift(lValue, iShiftBits)
Si iShiftBits = 0 Entonces
LMayús = lValor
Función de salida
De lo contrario, si iShiftBits = 31, entonces
Si lValue y 1 entonces
Cambio L = &H80000000
Demás
LMayús = 0
Terminar si
Función de salida
De lo contrario, si iShiftBits <0 o iShiftBits> 31, entonces
Err.Subir 6
Terminar si
Si (lValue y m_l2Power(31 - iShiftBits)) entonces
LShift = ((lValue y m_lOnBits(31 - (iShiftBits + 1))) * m_l2Power(iShiftBits)) O &H80000000
Demás
LShift = ((lValue y m_lOnBits(31 - iShiftBits)) * m_l2Power(iShiftBits))
Terminar si
Función final
Función privada RShift(lValue, iShiftBits)
Si iShiftBits = 0 Entonces
RMayús = lValor
Función de salida
De lo contrario, si iShiftBits = 31, entonces
Si lValue y &H80000000 entonces
Cambio R = 1
Demás
Cambio R = 0
Terminar si
Función de salida
De lo contrario, si iShiftBits <0 o iShiftBits> 31, entonces
Err.Subir 6
Terminar si
RShift = (lValor y &H7FFFFFFE) / m_l2Power(iShiftBits)
Si (lValue y &H80000000) entonces
RShift = (RShift O (&H40000000 / m_l2Power(iShiftBits - 1)))
Terminar si
Función final
Función privada Girar a la izquierda (lValue, iShiftBits)
GirarIzquierda = LShift(lValue, iShiftBits) o RShift(lValue, (32 - iShiftBits))
Función final
Función privada AddUnsigned(lX, lY)
x4
y4
x8
y8
Resultado tenue
lX8 = lX Y &H80000000
lY8 = lY y &H80000000
lX4 = lX y &H40000000
lY4 = lY y &H40000000
lResultado = (lX y &H3FFFFFFF) + (lY y &H3FFFFFFF)
Si lX4 y lY4 entonces
lResultado = lResultado Xor &H80000000 Xor lX8 Xor lY8
De lo contrario, si lX4 o lY4, entonces
Si lResult y &H40000000 entonces
lResultado = lResultado Xor &HC0000000 Xor lX8 Xor lY8
Demás
lResultado = lResultado Xor &H40000000 Xor lX8 Xor lY8
Terminar si
Demás
lResultado = lResultado Xo lX8 Xo lY8
Terminar si
Agregar sin firmar = lResultado
Función final
Función privada md5_F(x, y, z)
md5_F = (x e y) o ((no x) y z)
Función final
Función privada md5_G(x, y, z)
md5_G = (x y z) o (y y (no z))
Función final
Función privada md5_H(x, y, z)
md5_H = (x Xo y Xo z)
Función final
Función privada md5_I(x, y, z)
md5_I = (y Xor (x O (No z)))
Función final
Sub privado md5_FF(a, b, c, d, x, s, ac)
a = Agregar sin firmar (a, Agregar sin firmar (Agregar sin firmar (md5_F (b, c, d), x), ac))
a = Girar a la izquierda (a, s)
a = Agregar sin firmar (a, b)
Subtítulo final
Sub privado md5_GG(a, b, c, d, x, s, ac)
a = Agregar sin firmar (a, Agregar sin firmar (Agregar sin firmar (md5_G (b, c, d), x), ac))
a = Girar a la izquierda (a, s)
a = Agregar sin firmar (a, b)
Subtítulo final
Sub privado md5_HH(a, b, c, d, x, s, ac)
a = Agregar sin firmar (a, Agregar sin firmar (Agregar sin firmar (md5_H (b, c, d), x), ac))
a = Girar a la izquierda (a, s)
a = Agregar sin firmar (a, b)
Subtítulo final
Sub privado md5_II (a, b, c, d, x, s, ac)
a = Agregar sin firmar (a, Agregar sin firmar (Agregar sin firmar (md5_I (b, c, d), x), ac))
a = Girar a la izquierda (a, s)
a = Agregar sin firmar (a, b)
Subtítulo final
Función privada ConvertToWordArray(sMessage)
Longitud del mensaje tenue
Atenuar el número de palabras
Atenuar lWordArray()
Dim lBytePosition
Dim lByteCount
Atenuar el recuento de palabras
Constante MÓDULO_BITS = 512
Constante CONGRUENT_BITS = 448
lMessageLength = Len(sMensaje)
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)
lBytePosición = 0
lByteCount = 0
Hacer hasta lByteCount >= lMessageLength
lWordCount = lByteCount / BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) o LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)
lByteCount = lByteCount + 1
Bucle
lWordCount = lByteCount / BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) o LShift(&H80, lBytePosition)
lArrayPalabras(lNúmeroDePalabras - 2) = LShift(lLongitudMensaje, 3)
lArrayPalabras(lNúmeroDePalabras - 1) = RShift(lLongitudMensaje, 29)
ConvertToWordArray = lWordArray
Función final
Función privada WordToHex (lValue)
lByte tenue
recuento tenue
Para lCount = 0 a 3
lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) y m_lOnBits(BITS_TO_A_BYTE - 1)
WordToHex = WordToHex & Derecha(0 & Hex(lByte), 2)
Próximo
Función final
Función pública MD5 (sMensaje)
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(8) = 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_l2Potencia(0) = CLng(1)
m_l2Potencia(1) = CLng(2)
m_l2Potencia(2) = CLng(4)
m_l2Potencia(3) = CLng(8)
m_l2Potencia(4) = CLng(16)
m_l2Potencia(5) = CLng(32)
m_l2Potencia(6) = CLng(64)
m_l2Potencia(7) = CLng(128)
m_l2Potencia(8) = CLng(256)
m_l2Potencia(9) = CLng(512)
m_l2Potencia(10) = CLng(1024)
m_l2Potencia(11) = CLng(2048)
m_l2Potencia(12) = CLng(4096)
m_l2Potencia(13) = CLng(8192)
m_l2Potencia(14) = CLng(16384)
m_l2Potencia(15) = CLng(32768)
m_l2Potencia(16) = CLng(65536)
m_l2Potencia(17) = CLng(131072)
m_l2Potencia(18) = CLng(262144)
m_l2Potencia(19) = CLng(524288)
m_l2Potencia(20) = CLng(1048576)
m_l2Potencia(21) = CLng(2097152)
m_l2Potencia(22) = CLng(4194304)
m_l2Potencia(23) = CLng(8388608)
m_l2Potencia(24) = CLng(16777216)
m_l2Potencia(25) = CLng(33554432)
m_l2Potencia(26) = CLng(67108864)
m_l2Potencia(27) = CLng(134217728)
m_l2Potencia(28) = CLng(268435456)
m_l2Potencia(29) = CLng(536870912)
m_l2Potencia(30) = CLng(1073741824)
tenue x
tenue k
AA tenue
BB tenue
CC tenue
DimDD
atenuar un
tenue b
tenue c
tenue d
Constante S11 = 7
Constante S12 = 12
Constante S13 = 17
Constante S14 = 22
Constante S21 = 5
constante S22 = 9
Constante S23 = 14
Constante S24 = 20
Constante S31 = 4
Constante S32 = 11
Constante S33 = 16
constante S34 = 23
Constante S41 = 6
Constante S42 = 10
Constante S43 = 15
constante S44 = 21
x = ConvertToWordArray(sMensaje)
a = &H67452301
b = &HEFCDAB89
c = &H98BADCFE
re = &H10325476
Para k = 0 a UBound(x) Paso 16
AA = un
BB = b
CC = c
DD = d
md5_FF a, b, c, d, x(k + 0), S11, &HD76AA478
md5_FF d, a, b, c, x(k + 1), S12, y HE8C7B756
md5_FF c, d, a, b, x(k + 2), S13, &H242070DB
md5_FF b, c, d, a, x(k + 3), S14, &HC1BDCEEE
md5_FF a, b, c, d, x(k + 4), S11, &HF57C0FAF
md5_FF d, a, b, c, x(k + 5), S12, y H4787C62A
md5_FF c, d, a, b, x(k + 6), S13, &HA8304613
md5_FF b, c, d, a, x(k + 7), S14, &HFD469501
md5_FF a, b, c, d, x(k + 8), S11, y H698098D8
md5_FF d, a, b, c, x(k + 9), S12, &H8B44F7AF
md5_FF c, d, a, b, x(k + 10), S13, &HFFFF5BB1
md5_FF b, c, d, a, x(k + 11), S14, &H895CD7BE
md5_FF a, b, c, d, x(k + 12), S11, &H6B901122
md5_FF d, a, b, c, x(k + 13), S12, &HFD987193
md5_FF c, d, a, b, x(k + 14), S13, &HA679438E
md5_FF b, c, d, a, x(k + 15), S14, &H49B40821
md5_GG a, b, c, d, x(k + 1), S21, &HF61E2562
md5_GG d, a, b, c, x(k + 6), S22, &HC040B340
md5_GG c, d, a, b, x(k + 11), S23, &H265E5A51
md5_GG b, c, d, a, x(k + 0), S24, &HE9B6C7AA
md5_GG a, b, c, d, x(k + 5), S21 y HD62F105D
md5_GG d, a, b, c, x(k + 10), S22, &H2441453
md5_GG c, d, a, b, x(k + 15), S23, &HD8A1E681
md5_GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8
md5_GG a, b, c, d, x(k + 9), S21, &H21E1CDE6
md5_GG d, a, b, c, x(k + 14), S22, &HC33707D6
md5_GG c, d, a, b, x(k + 3), S23, &HF4D50D87
md5_GG b, c, d, a, x(k + 8), S24, &H455A14ED
md5_GG a, b, c, d, x(k + 13), S21, &HA9E3E905
md5_GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8
md5_GG c, d, a, b, x(k + 7), S23, &H676F02D9
md5_GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A
md5_HH a, b, c, d, x(k + 5), S31, &HFFFA3942
md5_HH d, a, b, c, x(k + 8), S32, &H8771F681
md5_HH c, d, a, b, x(k + 11), S33, &H6D9D6122
md5_HH b, c, d, a, x(k + 14), S34, &HFDE5380C
md5_HH a, b, c, d, x(k + 1), S31, &HA4BEEA44
md5_HH d, a, b, c, x(k + 4), S32, &H4BDECFA9
md5_HH c, d, a, b, x(k + 7), S33, &HF6BB4B60
md5_HH b, c, d, a, x(k + 10), S34, & HBEBFBC70
md5_HH a, b, c, d, x(k + 13), S31, &H289B7EC6
md5_HH d, a, b, c, x(k + 0), S32, &HEAA127FA
md5_HH c, d, a, b, x(k + 3), S33, &HD4EF3085
md5_HH b, c, d, a, x(k + 6), S34, &H4881D05
md5_HH a, b, c, d, x(k + 9), S31, &HD9D4D039
md5_HH d, a, b, c, x(k + 12), S32, &HE6DB99E5
md5_HH c, d, a, b, x(k + 15), S33, &H1FA27CF8
md5_HH b, c, d, a, x(k + 2), S34, &HC4AC5665
md5_II a, b, c, d, x(k + 0), S41, &HF4292244
md5_II d, a, b, c, x(k + 7), S42, &H432AFF97
md5_II c, d, a, b, x(k + 14), S43, &HAB9423A7
md5_II b, c, d, a, x(k + 5), S44, &HFC93A039
md5_II a, b, c, d, x(k + 12), S41, &H655B59C3
md5_II d, a, b, c, x(k + 3), S42, &H8F0CCC92
md5_II c, d, a, b, x(k + 10), S43, &HFFEFF47D
md5_II b, c, d, a, x(k + 1), S44, &H85845DD1
md5_II a, b, c, d, x(k + 8), S41, &H6FA87E4F
md5_II d, a, b, c, x(k + 15), S42, &HFE2CE6E0
md5_II c, d, a, b, x(k + 6), S43, &HA3014314
md5_II b, c, d, a, x(k + 13), S44, &H4E0811A1
md5_II a, b, c, d, x(k + 4), S41, &HF7537E82
md5_II d, a, b, c, x(k + 11), S42, &HBD3AF235
md5_II c, d, a, b, x(k + 2), S43, &H2AD7D2BB
md5_II b, c, d, a, x(k + 9), S44, &HEB86D391
a = Agregar sin firmar (a, AA)
b = Agregar sin firmar (b, BB)
c = Agregar sin firmar (c, CC)
d = Agregar sin firmar (d, DD)
Próximo
'MD5 = UCase(WordToHex(a) & WordToHex(b) & WordToHex(c) & WordToHex(d)) '32bytes
MD5 = LCase(WordToHex(b) & WordToHex(c)) 'Recorté esto para que se ajuste a la contraseña de la base de datos de 16 bytes :D
Función final
Función CFTGetServerDate(d)
Dim strTmp, iAño,iMes,iFecha
iAño = Año(d)
iMes = Mes(d)
iFecha = Día(d)
strTmp = CStr(iAño)
Si iMes < 10 entonces
strTmp = strTmp & 0 & Cstr(iMes)
Demás
strTmp = strTmp & Cstr(iMes)
Terminar si
Si iDate <10 entonces
strTmp = strTmp & 0 & Cstr(iFecha)
Demás
strTmp = strTmp & Cstr(iFecha)
Terminar si
CFTGetServerDate = strTmp
Función final
Función CFTGetServertime(d)
Dim strTmp, iAño,iMes,iFecha
iAño = hora(d)
iMes = minuto(d)
iFecha = segundo(d)
strTmp =
Si iAño < 10 entonces
strTmp = strTmp & 0 & Cstr(iAño)
Demás
strTmp = strTmp & Cstr(iAño)
Terminar si
Si iMes < 10 Entonces
strTmp = strTmp & 0 & Cstr(iMes)
Demás
strTmp = strTmp & Cstr(iMes)
Terminar si
Si iDate <10 entonces
strTmp = strTmp & 0 & Cstr(iFecha)
Demás
strTmp = strTmp & Cstr(iFecha)
Terminar si
CFTGetServertime = strTmp
Función final
función GetRnd(mín,máx)
Aleatorizar
ObtenerRnd = Int((máx - mínimo + 1) * Rnd + mínimo)
función final
función getrnddatenum()
getrnddatenum = CFTGetServerDate(ahora) & CFTGetServertime(ahora) & GetRnd(1000,9999)
función final
'PrivateKey, intenta ser lo más complicado posible. Una vez que comiences a usarla, no podrás cambiarla.
clave tenueinfokey
claveinfoclave = 51windows.net@1234567890!@#$%^&*()QWERFGHJK
'Obtén el código ganador
función obtener clave()
clave = getrnddatenum()
skey2 = md5(skey & keyinfokey)
getkey = clave y clave2
función final
'Verificar código ganador
tecla(s) de función
cadenas = s
si len(cadenas)<> 34 entonces
ckkey = falso
función de salida
terminar si
datenum = izquierda(cadenas,18)
md5oldstr = derecha(cadenas,16)
md5str = md5(numero de fecha y claveinfoclave)
si lcase(md5str) = lcase(md5oldstr) entonces
ckkey=verdadero
demás
ckkey = falso
terminar si
función final
%>