generateHashPassword(password) { let codeArr = _.shuffle(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']); codeArr = codeArr.slice(0, 10); const salt: string = codeArr.join(''); return this.encryptPassword(password, salt, this.configService.server.passSalt); }
private async generateSNSUsername(name) { const numArr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; const usernames = [ name + '_' + _.shuffle(numArr).slice(0, 4).join(''), name + '_' + _.shuffle(numArr).slice(0, 4).join(''), name + '_' + _.shuffle(numArr).slice(0, 4).join(''), name + '_' + _.shuffle(numArr).slice(0, 4).join(''), ]; const users = await this.userRepository.find({ select: ['id', 'username'], where: { username: In(usernames), }, }); for (const user of users) { for (let i = usernames.length - 1; i >= 0; i--) { if (user.username === usernames[i]) { usernames.splice(i, 1); } } } return usernames[0]; }
async sendSMSCode(phone: string): Promise<string> { let codeArr = _.shuffle([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); codeArr = codeArr.slice(0, 6); const code: string = codeArr.join(''); const accessKeyID = this.configService.aliyunSMS.accessKeyID; const accessKeySecret = this.configService.aliyunSMS.accessKeySecret; const smsClient = new SMSClient({accessKeyId: accessKeyID, secretAccessKey: accessKeySecret}); const res = await smsClient.sendSMS({ PhoneNumbers: phone, SignName: this.configService.aliyunSMS.signName, TemplateCode: this.configService.aliyunSMS.templateCode, TemplateParam: `{"code": "${code}"}`, }); if (res.Code === 'OK') { } else if (res.Code === 'isv.BUSINESS_LIMIT_CONTROL') { } return code; }
_.shuffle( Object.entries(questionsBySubcategory).flatMap(([, subQuestions]) => _.sampleSize(subQuestions, numQuestions[category]) ) )
function simulateClientLogin() { const account = _.shuffle('abcdefghijklnmopgrstuvwxyz'.split('')).join('').substring(0, 5); const interval = _.random(0, 10 / getBase() * 120) * 1000; client.write('login') .tag({ type: _.sample(['vip', 'member', 'member', 'member']), }) .field({ account, }) .set({ RP: rp, }) .then(() => { setTimeout(simulateClientLogin, interval); }).catch(err => { console.error(err); setTimeout(simulateClientLogin, interval); }); }
storage.reset() const addresses = _.shuffle(R.filter(i => (storage.config.allowIpv4 && !storage.servers[i].isIpv6) || (storage.config.allowIpv6 && storage.servers[i].isIpv6), R.keys(storage.servers))) const cnt = addresses.length if (cnt === 0) {