0

我目前正在使用jsencrypt公钥加密文本。这就是我所拥有的。

文件.jsx

import JsEncrypt  from 'jsencrypt';
const textEncrypt = 'sensitive data';
const encrypt = new JsEncrypt.JSEncrypt();
encrypt.setPublicKey(key);
const encryptedText = encrypt.encrypt(textEncrypt);
...

是否有另一个图书馆可以做到这一点?我正在阅读crypto-js但我不确定它是否在上面。

import JsEncrypt from 'jsencrypt';
import Cryptico from "cryptico";

function jsencryptMethod() {
    const encrypt = new JsEncrypt.JSEncrypt();
    encrypt.setPublicKey('mykey');
    return encrypt.encrypt('DE52**0978');
}

function crypticoMethod(){
    return Cryptico.encrypt('DE52**0978', 'mykey');
}

it('should be equal', async () => {
    expect(jsencryptMethod()).toEqual(crypticoMethod());
});

Error: expect(received).toEqual(expected) // deep equality

Expected: {"status": "Invalid public key"}
Received: false
4

0 回答 0