发布时间:2026-06-22阅读(1)
/** * 数字字符串 * @param {*} length * @returns */function randomWord1(length) { //指定长度: 默认长度8位 length || (length = 8); const numbers = 0123456789; const letters = ; let total = numbers letters; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}/** * 大写字母 数字字符串 * * @param {} length * @returns */function randomWord2(length) { //指定长度: 默认长度8位 length || (length = 8); const numbers = 0123456789; const letters = ABCDEFGHIJKLMNOPQRSTUVWXYZ; let total = numbers letters; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}/** * 小写字母 数字字符串 * * @param {} length * @returns */function randomWord3(length) { //指定长度: 默认长度8位 length || (length = 8); const numbers = 0123456789; const letters = abcdefghijklmnopqrstuvwxyz; let total = numbers letters; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}/** * 大小写字母 数字字符串 * * @param {*} length * @returns */function randomWord4(length) { //指定长度: 默认长度8位 length || (length = 8); //指定数字范围, const numbers = 0123456789; //指定字母范围,(也可以指定字符或者小写字母) const letters = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ; let total = numbers letters; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}/** * 常用特殊字符 大小写字母 数字字符串 * * @param {*} length * @returns */function randomWord5(length) { //指定长度: 默认长度8位 length || (length = 8); //指定数字范围, const numbers = 0123456789; //指定字母范围,(也可以指定字符或者小写字母) const letters = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ; //指定特殊字符 const specials = "~@#$%^&*()/.,"; let total = numbers letters specials; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}/** * 特殊字符 大小写字母 数字字符串 * * @param {*} length * @returns */function randomWord6(length) { //指定长度: 默认长度8位 length || (length = 8); //指定数字范围, const numbers = 0123456789; //指定字母范围,(也可以指定字符或者小写字母) const letters = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ; //指定特殊字符 const specials = "!#$%&()* ,-./:;<=>?@[\]^_`{|}~"; let total = numbers letters specials; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}// 数字【04970152848】console.log("randomWord1 = ", randomWord1(11));// 数字 大写字母【CE6532REAT7】console.log("randomWord2 = ", randomWord2(11));// 数字 小写字母【6a23t040nhu】console.log("randomWord3 = ", randomWord3(11));// 数字 大小写字母【0AC9U0t2CsI】console.log("randomWord4 = ", randomWord4(11));// 常用特殊字母 数字 大小写字母【hpj4~Catjb4】console.log("randomWord5 = ", randomWord5(32));// 特殊字母 数字 大小写字母【5Ra%x]N^8H】console.log("randomWord6 = ", randomWord6(11));,我来为大家讲解一下关于nodejs 加密算法?跟着小编一起来看一看吧!

nodejs 加密算法
生成随机码及密码 函数及代码/** * 数字字符串 * @param {*} length * @returns */function randomWord1(length) { //指定长度: 默认长度8位 length || (length = 8); const numbers = 0123456789; const letters = ; let total = numbers letters; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}/** * 大写字母 数字字符串 * * @param {} length * @returns */function randomWord2(length) { //指定长度: 默认长度8位 length || (length = 8); const numbers = 0123456789; const letters = ABCDEFGHIJKLMNOPQRSTUVWXYZ; let total = numbers letters; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}/** * 小写字母 数字字符串 * * @param {} length * @returns */function randomWord3(length) { //指定长度: 默认长度8位 length || (length = 8); const numbers = 0123456789; const letters = abcdefghijklmnopqrstuvwxyz; let total = numbers letters; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}/** * 大小写字母 数字字符串 * * @param {*} length * @returns */function randomWord4(length) { //指定长度: 默认长度8位 length || (length = 8); //指定数字范围, const numbers = 0123456789; //指定字母范围,(也可以指定字符或者小写字母) const letters = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ; let total = numbers letters; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}/** * 常用特殊字符 大小写字母 数字字符串 * * @param {*} length * @returns */function randomWord5(length) { //指定长度: 默认长度8位 length || (length = 8); //指定数字范围, const numbers = 0123456789; //指定字母范围,(也可以指定字符或者小写字母) const letters = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ; //指定特殊字符 const specials = "~!@#$%^&*()/.,"; let total = numbers letters specials; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}/** * 特殊字符 大小写字母 数字字符串 * * @param {*} length * @returns */function randomWord6(length) { //指定长度: 默认长度8位 length || (length = 8); //指定数字范围, const numbers = 0123456789; //指定字母范围,(也可以指定字符或者小写字母) const letters = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ; //指定特殊字符 const specials = "!#$%&()* ,-./:;<=>?@[\]^_`{|}~"; let total = numbers letters specials; let result = ; while (length > 0) { length--; result = total[Math.floor(Math.random() * total.length)]; } return result;}// 数字【04970152848】console.log("randomWord1 = ", randomWord1(11));// 数字 大写字母【CE6532REAT7】console.log("randomWord2 = ", randomWord2(11));// 数字 小写字母【6a23t040nhu】console.log("randomWord3 = ", randomWord3(11));// 数字 大小写字母【0AC9U0t2CsI】console.log("randomWord4 = ", randomWord4(11));// 常用特殊字母 数字 大小写字母【hpj4~Catjb4】console.log("randomWord5 = ", randomWord5(32));// 特殊字母 数字 大小写字母【5Ra%x]N^8H】console.log("randomWord6 = ", randomWord6(11));
Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图