@0x/contracts-test-utils
: Add hexRandom()
to hex_utils.ts
.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import * as crypto from 'crypto';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
|
||||
/**
|
||||
@@ -6,3 +7,9 @@ import * as ethUtil from 'ethereumjs-util';
|
||||
export function hexConcat(...args: Array<string | number | Buffer>): string {
|
||||
return ethUtil.bufferToHex(Buffer.concat(args.map(h => ethUtil.toBuffer(h))));
|
||||
}
|
||||
/**
|
||||
* Generate a random hex string.
|
||||
*/
|
||||
export function hexRandom(size: number = 32): string {
|
||||
return ethUtil.bufferToHex(crypto.randomBytes(size));
|
||||
}
|
||||
|
Reference in New Issue
Block a user