Skip to content

Instantly share code, notes, and snippets.

@loveyunk
Last active November 5, 2018 09:44
Show Gist options
  • Save loveyunk/d59a4ad288a01a1be1c1acea5824b1f4 to your computer and use it in GitHub Desktop.
Save loveyunk/d59a4ad288a01a1be1c1acea5824b1f4 to your computer and use it in GitHub Desktop.
非对称加密
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="./jsencrypt.min.js"></script>
<script>
// 公钥
const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCRQZ5O/AOAjeYAaSFf6Rjhqovws78I716I9oGF7WxCIPmcaUa1YuyLOncCCuPsaw69+RMWjdbOBp8hd4PPM/d4mKTOVEYUE0SfxhhDTZaM5CzQEUXUyXy7icQTGR5wBjrbjU1yHCKOf5PJJZZQWB06husSFZ40TdL7FdlBpZ1u1QIDAQAB';
let crypt = new JSEncrypt();
crypt.setPublicKey(publicKey);
// 密码
let password = '123456';
// 加密
let enc = crypt.encrypt(password);
console.log(enc);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment