Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default str => {
let encrypt = new JSEncrypt()
encrypt.setPublicKey(key)
// console.log(str)
return encrypt.encrypt(str)
}
Vue.prototype.$encruption = function (obj) {
let encrypt = new JsEncrypt();
encrypt.setPublicKey(
`-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDyKmfJhgAHEK0Yo6qOtFB8sSfYIZBJUyyXi1X7EgkZo3kmMOu6/uT7SwC9EnqbiMySJfAlvB200ZMIk6e1NQrPLZpc5VSuzSQ3NqdXOdbNnhXAUeME8IcsbscK9XP8BxldMhUhIK+3zovI1VCY2kLO6TMwEVvTdH+F1jW/WFkplwIDAQAB-----END PUBLIC KEY-----`
)
return encrypt.encrypt(obj);
};
export const decryptAsymmetric = (privateKey, encryptedText) => {
const crypt = new JSEncrypt();
crypt.setPrivateKey(privateKey);
return crypt.decrypt(encryptedText);
};
encrypt(publicKey, password) {
var en = new JSEncrypt();
en.setPublicKey(publicKey);
return en.encrypt(password);
},
verify() {
export const encryptAsymmetric = (publicKey, actualText) => {
const crypt = new JSEncrypt();
crypt.setPublicKey(publicKey);
return crypt.encrypt(actualText);
};
export const generateAsymmetricKeyPair = (keySize = 1024) => {
const crypt = new JSEncrypt({ default_key_size: keySize });
const keys = crypt.getKey();
return {
privateKey: keys.getPrivateKey(),
publicKey: keys.getPublicKey()
};
};