zoukankan      html  css  js  c++  java
  • 几种常用的前端加密

    1、base64:

    <!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">
        <script src="base64.js"></script>
        <title>base64加密</title>
    </head>
    <body>
        <script>
            var rule = new Base64()
            var pwd = '123456' 
            // 加密
            var encryption = rule.encode('password:'+pwd)
            console.log(encryption) //cGFzc3dvcmQ6MTIzNDU2
            // 解密
            encryption = rule.decode(encryption); 
            console.log(encryption) //password:123456
        </script>
    </body>
    </html>

    2、md5:

    <!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">
        <script src="md5.js"></script>
        <title>md5加密</title>
    </head>
    <body>
        <script>
            var pwd = '123456' 
            // 加密
            var encryption = hex_md5('password:'+pwd)
            console.log(encryption) //cc4452544b7f1a162452444f49238de8
        </script>
    </body>
    </html>

    3、sha1

    <!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">
        <script src="sha1.js"></script>
        <title>sha1加密</title>
    </head>
    <body>
        <script>
            var pwd = '123456' 
            // 加密
            var encryption = hex_sha1('password:'+pwd)
            console.log(encryption) //b48d0965a80dfad4ad6db7e98ce666d8226619bb
        </script>
    </body>
    </html>

    4、RSA

    <!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">
        <script src="jsencrypt.js"></script>
        <title>RSA加密</title>
    </head>
    <body>
        <script>
            var pwd = '123456' 
            // 加密
            var encrypt = new JSEncrypt();
            var encryptStr = encrypt.encrypt('password :'+pwd);
            console.log(encryptStr);//(每次都在变化)
            // 解密
            var decryptStr = encrypt.decrypt(encryptStr);
            console.log(decryptStr); //password :123456
        </script>
    </body>
    </html>
  • 相关阅读:
    【Java例题】3.1 7、11、13的倍数
    【Java例题】2.7找零钱
    【Java例题】2.6 三角形的面积
    【Java例题】2.5 温度转换
    【Java例题】2.4求函数
    【Java例题】2.2 分数类
    【Java例题】2.3 计算银行存款本息
    博客园里面关于abpZero的好的教程
    IOC学习1
    1.开始第一个MVC项目
  • 原文地址:https://www.cnblogs.com/C-target/p/11335444.html
Copyright © 2011-2022 走看看