mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
install: use crypto.randomBytes to generate password
This commit is contained in:
1 file changed
+2
-7
+2
-7
@@ -2,6 +2,7 @@
|
|||||||
/* eslint-disable import/no-dynamic-require */
|
/* eslint-disable import/no-dynamic-require */
|
||||||
/* eslint-disable no-sequences */
|
/* eslint-disable no-sequences */
|
||||||
import { execSync, ExecSyncOptions } from 'child_process';
|
import { execSync, ExecSyncOptions } from 'child_process';
|
||||||
|
import crypto from 'crypto';
|
||||||
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
||||||
import net from 'net';
|
import net from 'net';
|
||||||
import os, { cpus } from 'os';
|
import os, { cpus } from 'os';
|
||||||
@@ -128,13 +129,7 @@ if (!cpuInfoFile.includes('avx') && !installAsJudge) {
|
|||||||
}
|
}
|
||||||
let retry = 0;
|
let retry = 0;
|
||||||
log.info('install.start');
|
log.info('install.start');
|
||||||
const defaultDict = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
let password = crypto.randomBytes(32).toString('hex');
|
||||||
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);
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
let CN = true;
|
let CN = true;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user