大家下午好
我正在Wix.com网站上寻找有关如何使用HMAC / SHA156正确生成内容哈希的信息,该网站使用Corvid进行编码。我对编码非常陌生,希望能收到反馈。
这是我的后端代码:
import { fetch } from 'wix-fetch';
import {wixData} from 'wix-data';
import * as HMAC from 'public/hmac';
import * as Core from 'public/core';
import * as Base64 from 'public/enc.base64';
import * as SHA256 from 'public/sha256';
import * as jquery from 'public/jquery';
import * as HmacSHA256 from 'public/hmac-sha256';
import * as CryptoJS from 'public/crypto-js';
import wixUsers from 'wix-users-backend';
$w.onReady(function () {
});
export function createLoyalty(customerInfo) {
function conversion() {
var secret = "signature";
var string2Sign = body;
var hash = CryptoJS.HmacSHA256(string2Sign, secret);
var signature = CryptoJS.enc.Base64.stringify(hash);
}
const url = "https://whisqr.com/api/v1.2/user/customer/";
const headers = {
"X-Public": 'xxxxxxxAPI Public Keyxxxxxxx', //
"X-Hash": "signature",
"Content-Type": "application/json" //the content type
};
let body = {
"email": "email",
"firstname": "firstName",
"password": "password"
};
return fetch(url, {
"method": "POST",
"timeout": 0,
"headers": headers,
"body": JSON.stringify(body) //if there is a body
})
}
这是我的表单页面代码:
import {wixData} from 'wix-data';
import {fetch} from 'wix-fetch';
import {createLoyalty} from 'backend/Loyalty';
import wixLocation from 'wix-location';
$w.onReady(function () {
});
export function signupbtn_Click(event, $w) {
let customerInfo = `${$w('#input3').value} ${$w('#input1').value} ${$w('#input4').value}`;
createLoyalty(customerInfo)
.then(loyalty => {
console.log("member created");
wixLocation.to("/striking-pursuits/loyalty")
}
);
}