系统、网站、API站点,简单高效开发

平台介绍 >> js/jsfun/fnCrypto.js 加密操作类

js/jsfun/fnCrypto.js 加密操作类

  let key = "crypto_key"

    //MD5 加密
    console.log("MD5(123456):", fnCrypto_md5("123456"));
    let salt = "12345678"
    let aes = fnCrypto_aesEncrypt("123456", salt);
    console.log("aes(123456):", aes);
    console.log("aes(123456):", fnCrypto_aesDecrypt(aes, salt));


    let publicKey = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcEUAg8j55PvsQqEEcFAaGyrWI
L/CroWdpoE6A8JK/E3pXZbPwJ8s6rfbPQLpkBKXVOP2/uzOHDL4ty+NFeWIbxlY2
lab80NfuRpIOEUnk4dB76BTwbwu4OtkflQ9kBr79c8wSussAR/EkOKvvBsZULeMF
27E+J+lG6gRaoBSALQIDAQAB
-----END PUBLIC KEY-----`;
    let privateKey = `-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDcEUAg8j55PvsQqEEcFAaGyrWIL/CroWdpoE6A8JK/E3pXZbPw
J8s6rfbPQLpkBKXVOP2/uzOHDL4ty+NFeWIbxlY2lab80NfuRpIOEUnk4dB76BTw
bwu4OtkflQ9kBr79c8wSussAR/EkOKvvBsZULeMF27E+J+lG6gRaoBSALQIDAQAB
AoGBAJVUY1a36qqtkQIpmhzqfc9DiFFEbqSYHqsvK3YVSQ69sdvSWHqTFjXYTE0w
mAo8mScJyC4tYna2r+o1mx/OkUITV6LxVrB/IcW44vTirL4uG0ubqOI6mCVLt9dG
V1n9lifo3F5JuvlfgTVHwb6YG8U5+dTqp9810bPWcCGzBs9FAkEA9PuiJqFXxmgz
KU/Nu4TAUjoRxmOZ+JtH36pPqL9FEH0wkH8pHMaPj2P+KqB8l4jYIhHCaSW7L0+R
0uRcvlGocwJBAOX2xtUfXa74CpXoGWBzXa8hejoqsrzRF5i4Po6wv6gcYra7Rsfm
i8A+mgPlUEOyCSQTQ1dM5fT5av23Nz1FLN8CQQCdo4oMp4dusUAylhqBToPepWUo
rpC2K11NbC8EG8faO2RTpq+Sx6Y7E5HKZiil7bV9/sWFmXTglaf092NCSBNHAkBh
w/ZoKPuVJVKqxI/1V1ae2+awz/JJH8OeY8YEt9PjTp4Q/bFrzvHe+z5TJaxn+0qz
kZTxinnBGkCIONo9LCmVAkEAiHvTCKEtUTplzmZcd6guZ538e2czBHhtKJFtcHT4
ydDZMXaTzbO65q3N5T6Vwl0gorKzRYo2OE2DHosoWhBd8Q==
-----END RSA PRIVATE KEY-----`

    let rsa = fnCrypto_rsaEncrypt("123456", publicKey)
    console.log("RSA_en:", rsa)
    console.log("RSA_de:", fnCrypto_rsaDecrypt(rsa, privateKey))

    let desCbc = fnCrypto_desCbcEncrypt("123456", salt)
    console.log("desCbc_en:", desCbc)
    console.log("desCbc_de:", fnCrypto_desCbcDecrypt(desCbc, salt))

    let desEcb = fnCrypto_desEcbEncrypt("123456", salt)
    console.log("desEcb_en:", desEcb)
    console.log("desEcb_de:", fnCrypto_desEcbDecrypt(desEcb, salt))

备案号:闽ICP备20003806号     厦门市湖里区陈朝能网络技术工作室