MCPcopy Index your code
hub / github.com/parse-community/parse-server / randomString

Function randomString

src/cryptoUtils.js:22–33  ·  view source on GitHub ↗
(size: number)

Source from the content-addressed store, hash-verified

20// (256) evenly. Such bias is acceptable for most cases when the output
21// length is long enough and doesn't need to be uniform.
22export function randomString(size: number): string {
23 if (size === 0) {
24 throw new Error('Zero-length randomString is useless.');
25 }
26 const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789';
27 let objectId = '';
28 const bytes = randomBytes(size);
29 for (let i = 0; i < bytes.length; ++i) {
30 objectId += chars[bytes.readUInt8(i) % chars.length];
31 }
32 return objectId;
33}
34
35// Returns a new random alphanumeric string suitable for object ID.
36export function newObjectId(size: number = 10): string {

Callers 6

sendSMSMethod · 0.90
setupTOTPMethod · 0.90
setEmailVerifyTokenMethod · 0.90
setPasswordResetTokenMethod · 0.90
newObjectIdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected