首页 > 其他 > 详细

dfd

时间:2019-09-09 11:25:10      阅读:70      评论:0      收藏:0      [点我收藏+]

 

<!DOCTYPE html>
<html>
<head>
  <script src="crypto-js.min.js"></script>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
  <script src="http://passport.cnblogs.com/scripts/jsencrypt.min.js"></script>
  <script type="text/javascript">
    // 使用jsencrypt类库加密js方法,
    function encryptRequest(reqUrl, data, publicKey) {
      var encrypt = new JSEncrypt();
      encrypt.setPublicKey(publicKey);
      // ajax请求发送的数据对象
      var sendData = new Object();
      // 将data数组赋给ajax对象
      for (var key in data) {
        sendData[key] = encrypt.encrypt(data[key]);
      }
      console.info(sendData);
      $.ajax({
        url: reqUrl,
        type: post,
        data: sendData,
        dataType: json,
        //contentType: ‘application/json; charset=utf-8‘,
        success: function (data) {
          console.info(data);
        },
        error: function (xhr) {
          //console.error(‘出错了‘);
        }
      });
    }
    // Call this code when the page is done loading.
    $(function () {
      $(#testme).click(function () {
        var data = [];
        data[username] = $(#username).val();
        data[passwd] = $(#passwd).val();
        var pkey = $(#pubkey).val();
        encryptRequest(/, data, pkey);
      });
    });
  </script>
</body>
</html>

 

dfd

原文:https://www.cnblogs.com/sea-stream/p/11490174.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!