FOROS PROFESIONALES
WINDEV
,
WEBDEV
y
WINDEV Mobile
Inicio
|
Mensajes recientes
|
Conéctese...
|
Desconectar
|
Español
Inicio
→
WINDEV 2024
→
Why does Hash and Base64 have different results(is it wrong?)
Why does Hash and Base64 have different results(is it wrong?)
Iniciado por Mick, 13,ene. 2021 05:16 - 3 respuestas
Conéctese…
Mick
#1
Publicado el 13,enero 2021 - 05:16
windev code:
secretKey is string= "Gu5t9xGARNpq86cd98joQYCN3*******"
srcStr is string = "GETcvm.tencentcloudapi.com/?Action=DescribeInstances&InstanceIds.0=ins-09dx96dg&Limit=20&Nonce=11886&Offset=0&Region=ap-guangzhou&SecretId=AKIDz8krbsJ5yKBZQpn74WFkmLPx3*******&Timestamp=1465185768&Version=2017-03-12"
signStr is string = Encode(HashString(HA_HMAC_SHA_160,srcStr,secretKey),encodeBASE64)
trace(signStr) //the result is "5PaiqVPaSxwQrIfjSGO8wQ+nozE="
php code:
$secretKey = 'Gu5t9xGARNpq86cd98joQYCN3*******';
$srcStr = 'GETcvm.tencentcloudapi.com/?Action=DescribeInstances&InstanceIds.0=ins-09dx96dg&Limit=20&Nonce=11886&Offset=0&Region=ap-guangzhou&SecretId=AKIDz8krbsJ5yKBZQpn74WFkmLPx3*******&Timestamp=1465185768&Version=2017-03-12';
$signStr = base64_encode(hash_hmac('sha1', $srcStr, $secretKey, true));
echo $signStr;
//the resule is "zmmjn35mikh6pM3V7sUEuX4wyYM="
the result is diffrent, and the PHP result is Official.Why???
Informar
0
0
Guenter
#2
Miembro registrado
14 mensajes
Publicado el 14,enero 2021 - 06:52
It's simple: the functions Hash and Encode are two different things. Hash: the source string is unrecoverable. Encode: the source string is recoverable.
--
Gunter Predl
paypal@windev.at
Informar
0
0
Tucat
#3
Publicado el 15,enero 2021 - 14:29
HashString treats the input strings as a raw bytes, therefore the ANSI vs UNICODE character encoding is critical. Change the secretKey and srcStr declarations to 'ANSI String' and your code will produce the same output as the php version.
Informar
0
0
Mick
#4
Publicado el 26,enero 2021 - 05:45
the problem was solved.the hashstring string,i use stringtouft8
Informar
0
0
→ Volver a WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (versiones precedentes)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Búsqueda Tipo
Sólo temas
Todos los mensajes
Periodo Buscar
Cualquier fecha
Última hora
Última 24 horas
Última semana
Último mes
Último año
Cancelar
Vista previa del mensaje
Añadiendo una imagen
Importar una imagen desde una URL
Enviar una imagen desde un archivo de su disco
Arrastrar un archivo o click en "Examinar..."
o
Cancelar
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Texto