@@ -8,7 +8,7 @@ export function randomHexString(size: number): string {
|
||||
throw new Error('Zero-length randomHexString is useless.');
|
||||
}
|
||||
if (size % 2 !== 0) {
|
||||
throw new Error('randomHexString size must be divisible by 2.')
|
||||
throw new Error('randomHexString size must be divisible by 2.');
|
||||
}
|
||||
return randomBytes(size / 2).toString('hex');
|
||||
}
|
||||
@@ -23,9 +23,8 @@ export function randomString(size: number): string {
|
||||
if (size === 0) {
|
||||
throw new Error('Zero-length randomString is useless.');
|
||||
}
|
||||
const chars = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
|
||||
'abcdefghijklmnopqrstuvwxyz' +
|
||||
'0123456789');
|
||||
const chars =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789';
|
||||
let objectId = '';
|
||||
const bytes = randomBytes(size);
|
||||
for (let i = 0; i < bytes.length; ++i) {
|
||||
@@ -45,5 +44,7 @@ export function newToken(): string {
|
||||
}
|
||||
|
||||
export function md5Hash(string: string): string {
|
||||
return createHash('md5').update(string).digest('hex');
|
||||
return createHash('md5')
|
||||
.update(string)
|
||||
.digest('hex');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user