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>
  • 相关阅读:
    javascript 操作 excel 全攻略
    ASP.NET中上传并读取Excel文件数据
    创意无限!一组网页边栏过渡动画【附源码下载】
    jQuery一些常用特效方法使用实例
    jQuery的deferred对象详解
    Jquery 数组操作
    10 款精美的 CSS3 全新特效
    20 个用于处理页面滚动效果的 jQuery 插件
    Linux-exec命令试验驱动(12)
    动态规划-数正方形(详解)
  • 原文地址:https://www.cnblogs.com/C-target/p/11335444.html
Copyright © 2011-2022 走看看