将 JS crypto.createHmac 翻译成 Xojo Crypto.HMAC
Translating JS crypto.createHmac to Xojo Crypto.HMAC
我正在尝试翻译 Javascript 中的这个块:
const crypto = require('crypto'),
shared_key = 'kw4qSnpSwXzgiv5yxYpZZmFEd9QAeiKTQ6OuyMja',
signing_string = 'licenseSpring\ndate: Tue, 07 Jun 2011 20:51:35 GMT';
let signature = crypto.createHmac('sha256', shared_key).update(signing_string).digest('base64');
console.log(signature);
// UDysfR6MndUZReo07Y9r+vErn8vSxrnQ5ulit18iJ/Q=
进入Xojo:
Var shared_key as String = "kw4qSnpSwXzgiv5yxYpZZmFEd9QAeiKTQ6OuyMja"
Var signing_string as String = "licenseSpring\ndate: Tue, 07 Jun 2011 20:51:35 GMT"
Var hash As String
hash = EncodeBase64(Crypto.HMAC(shared_key, signing_string, Crypto.HashAlgorithms.SHA256))
MessageBox(hash)
//Q4BAhsu1Xw3LsBZ+BCLShWQDbmJ2j/eFXzvF9T6n9tU=
我得到两个不同的散列字符串,但希望它们应该相同。这些算法是否等效?
原来是这样的:
Var signing_string as String = "licenseSpring" + EndOfLine.UNIX + "date: Tue, 07 Jun 2011 20:51:35 GMT"
我正在尝试翻译 Javascript 中的这个块:
const crypto = require('crypto'),
shared_key = 'kw4qSnpSwXzgiv5yxYpZZmFEd9QAeiKTQ6OuyMja',
signing_string = 'licenseSpring\ndate: Tue, 07 Jun 2011 20:51:35 GMT';
let signature = crypto.createHmac('sha256', shared_key).update(signing_string).digest('base64');
console.log(signature);
// UDysfR6MndUZReo07Y9r+vErn8vSxrnQ5ulit18iJ/Q=
进入Xojo:
Var shared_key as String = "kw4qSnpSwXzgiv5yxYpZZmFEd9QAeiKTQ6OuyMja"
Var signing_string as String = "licenseSpring\ndate: Tue, 07 Jun 2011 20:51:35 GMT"
Var hash As String
hash = EncodeBase64(Crypto.HMAC(shared_key, signing_string, Crypto.HashAlgorithms.SHA256))
MessageBox(hash)
//Q4BAhsu1Xw3LsBZ+BCLShWQDbmJ2j/eFXzvF9T6n9tU=
我得到两个不同的散列字符串,但希望它们应该相同。这些算法是否等效?
原来是这样的:
Var signing_string as String = "licenseSpring" + EndOfLine.UNIX + "date: Tue, 07 Jun 2011 20:51:35 GMT"