馆内加密
这个图书馆是一个小包装 围绕节点 crypto 图书馆。 它为在AES和RSA中加密和破解任意有效载荷提供了方便方法.
为使用加密/解密Anvil的有效载荷,您可以从您的 组织的设置页面。 。 。 .

安维尔 为所有文件提供方便的API.
- PDF 填补 API - 填写一个PDF模板,其中包含网络请求和结构化的JSON数据.
- PDF 生成 API - 发送标记下来或HTML和Anvil会把它变成PDF.
- Etch 带有 API 的 E 签名 - 可自定义的、可嵌入的、带有API的电子签名平台,以控制签名过程的端到端.
- 工作流量(w/ API) - Webforms + PDF + E- sign 带有强大的无码构建器. 轻松地收集结构化数据,生成PDF,并请求签名.
多了解一下安维尔 Anvil 开发者页面。 。 。 .
安装
yarn add @anvilco/encryption
那就用这个
// For RSA functions
import { encryptRSA, decryptRSA } from '@anvilco/encryption'
// For AES functions
import { generateAESKey, encryptAES, decryptAES } from '@anvilco/encryption'
// Could grab the keys from file (or preferably from environment variables)
import fs from 'fs'
const privateKey = fs.readFileSync('path/to/privateKey.pem')
const publicKey = fs.readFileSync('path/to/publicKey.pem')
// RSA
const message = 'Super secret message'
const encryptedRSAMessage = encryptRSA(publicKey, message)
const origRSAMessage = decryptRSA(privateKey, encryptedRSAMessage)
console.log(origRSAMessage === message) // => true
// AES
const aesKey = generateAESKey()
const encryptedAESMessage = encryptAES(aesKey, message)
const origAESMessage = decryptAES(aesKey, encryptedAESMessage)
console.log(origAESMessage === message) // => true
API 密码
RSA有两个功能: encryptRSA, (中文(简体) ), decryptRSA,AES则有三: generateAESKey, (中文(简体) ), encryptAES, (中文(简体) ), decryptAES。 。 。 .
高级
AES有三个功能:
key = generateAESKey()encryptedMessage = encryptAES(key, plainMessage)plainMessage = decryptAES(key, encryptedMessage)
encryptAES 创建一个独特的 四、结 论 对每封信件进行加密,并预留到产生的加密有效载荷上。 这么说吧 encryptedMessage 将采用格式
<iv>:<aesEncryptedPayload>
登记册系统管理人
RSA有两个功能:
encryptedMessage = encryptRSA(publicKey, plainMessage)plainMessage = decryptRSA(privateKey, encryptedMessage)
这些函数用RSA加密/解密 财务报告和审定财务报表 没错 RSA对它能加密多少数据有上限. 所以我们创建一个AES密钥,用RSA加密AES密钥,然后用AES加密实际消息.
注意加密的有效载荷(结果 encryptRSA)的格式:
<rsaEncryptedAESKey>:<aesEncryptedMessage>
生成 RSA 密钥
此库无法生成 RSA 密钥 .
您可以使用打开sl:
# This generates a 2048 bit private key to file
openssl genrsa -out privateKey.pem 2048
# This extracts the public key to file
openssl rsa -in privateKey.pem -outform PEM -pubout -out publicKey.pem
你也可以使用类似的东西 节点-rsa数字 :
// Example generating a RSA keypair with node-rsa
import NodeRSA from 'node-rsa'
function generateRSAKeypair () {
const key = new NodeRSA()
key.generateKeyPair(2048, 65537)
return {
publicKey: key.exportKey('pkcs8-public-pem'),
privateKey: key.exportKey('pkcs8-private-pem'),
}
}
许可证
麻省理工学院