Skip to content

Commit

Permalink
install: use crypto.randomBytes to generate password
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-moe committed Jan 20, 2025
1 parent 3ea0699 commit 4c3e2c1
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions install/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint-disable import/no-dynamic-require */
/* eslint-disable no-sequences */
import { execSync, ExecSyncOptions } from 'child_process';
import crypto from 'crypto';
import { existsSync, readFileSync, writeFileSync } from 'fs';
import net from 'net';
import os, { cpus } from 'os';
Expand Down Expand Up @@ -128,13 +129,7 @@ if (!cpuInfoFile.includes('avx') && !installAsJudge) {
}
let retry = 0;
log.info('install.start');
const defaultDict = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
function randomstring(digit = 32, dict = defaultDict) {
let str = '';
for (let i = 1; i <= digit; i++) str += dict[Math.floor(Math.random() * dict.length)];
return str;
}
let password = randomstring(32);
let password = crypto.randomBytes(32).toString('hex');
// eslint-disable-next-line
let CN = true;

Expand Down

0 comments on commit 4c3e2c1

Please sign in to comment.