MCPcopy Create free account
hub / github.com/develop202/migu_video / RSAencrypt

Function RSAencrypt

utils/EncryUtils.js:102–115  ·  view source on GitHub ↗

* RSA 私钥签名加密 * @param {string} data - * @param {string} publicKeyBase - * @returns {string} -

(data, publicKeyBase = RSA_PRIVATE_KEY_PKCS8)

Source from the content-addressed store, hash-verified

100 * @returns {string} -
101 */
102function RSAencrypt(data, publicKeyBase = RSA_PRIVATE_KEY_PKCS8) {
103 const clearKey = publicKeyBase.replace(/\r/g, "")
104 const keyBytes = Buffer.from(clearKey, "base64")
105 const privateKey = crypto.createPrivateKey({
106 key: keyBytes,
107 format: "der",
108 type: "pkcs8"
109 })
110 const dest = crypto.privateEncrypt({
111 key: privateKey,
112 padding: crypto.constants.RSA_PKCS1_PADDING,
113 }, data)
114 return dest.toString("base64")
115}
116
117export { getStringMD5, AESdecrypt, AESencrypt, Base64decrypt, Base64encrypt, RSAencrypt }

Callers 1

refreshTokenFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected