zoukankan      html  css  js  c++  java
  • 对输入密码的一个加密规则和方式的编写

    getPwd () {
          this.form.pwd = this.randomPassword(8)
        },
        randomPassword(length) {
          length = Number(length)
          // Limit length
          if (length < 8) {
            length = 8
          } else if (length > 16) {
            length = 16
          }
          let passwordArray = ['ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz', '1234567890', '@#$%&'];
          var password = [];
          let n = 0;
          for (let i = 0; i < length; i++) {
            // If password length less than 9, all value random
            if ( password.length < (length - 4) ) {
              // Get random passwordArray index
              let arrayRandom = Math.floor(Math.random() * 4);
              // Get password array value
              let passwordItem = passwordArray[arrayRandom];
              // Get password array value random index
              // Get random real value
              let item = passwordItem[Math.floor(Math.random() * passwordItem.length)];
              password.push(item);
            } else {
              // If password large then 9, lastest 4 password will push in according to the random password index
              // Get the array values sequentially
              let newItem = passwordArray[n];
              let lastItem = newItem[Math.floor(Math.random() * newItem.length)];
              // Get array splice index
              let spliceIndex = Math.floor(Math.random() * password.length);
              password.splice(spliceIndex, 0, lastItem);
              n++
            }
          }
          return password.join("");
        }

  • 相关阅读:
    SharePoint 2013 APP 开发示例 (六)服务端跨域访问 Web Service (REST API)
    麦咖啡导致电脑不能上网
    SharePoint 2013 Central Admin 不能打开
    SharePoint 2013 APP 开发示例 (五)跨域访问 Web Service (REST API)
    SharePoint 2013 APP 开发示例 系列
    synthesize(合成) keyword in IOS
    Git Cmd
    简单的正则匹配
    Dropbox
    SQL Server Replication
  • 原文地址:https://www.cnblogs.com/robot666/p/12080914.html
Copyright © 2011-2022 走看看