UNPKG

@cloudbase/lowcode-deployer

Version:

deploy weda app

21 lines (20 loc) 687 B
"use strict"; const TceCloudSDKHttpException = require("./exception/tce_cloud_sdk_exception"); const crypto = require('crypto'); /** * @inner */ class Sign { static sign(secretKey, signStr, signMethod) { let signMethodMap = { HmacSHA1: "sha1", HmacSHA256: "sha256" }; if (!signMethodMap.hasOwnProperty(signMethod)) { throw new TceCloudSDKHttpException("signMethod invalid, signMethod only support (HmacSHA1, HmacSHA256)"); } let hmac = crypto.createHmac(signMethodMap[signMethod], secretKey || ""); return hmac.update(Buffer.from(signStr, 'utf8')).digest('base64'); } } module.exports = Sign;