Overview
The Random String Generator creates cryptographically secure random strings using crypto.getRandomValues(). Generate alphanumeric strings, hex values, base64 tokens, or memorable passphrases for passwords, API keys, and test data.
Use Cases
Password Generation : Create strong, random passwords
API Keys : Generate secure tokens for API authentication
Test Data : Create random identifiers for testing
Salts and Nonces : Generate cryptographic salts and nonces
Session IDs : Create unique session identifiers
Passphrases : Generate memorable word-based passwords
Configure generation via the second input (config format):
Configuration Options
length : Character/word length (1-4096, default: 32)
count : Number of strings to generate (1-100, default: 1)
Output Modes
Alphanumeric (default)
Generate random strings with uppercase, lowercase, and digits:
K7mP9xQwR3nB8vZa
T2dF6yHj4cN1sL9p
W5gA8rV3mX7kE2qU
Hex
Generate hexadecimal strings (0-9, a-f):
8f4e2a9c1b6d3f7e9a2c5b8d1f4e6a9c
c3b7f1e9d5a2c8f4e6b9d3a7c1f8e5b2
Base64
Generate base64-compatible strings:
K8mP+xQwR3nB/vZaT2dF6yHj
W5gA8rV3mX7kE2qUT9cN1sLp
Symbols
Generate strings with special characters:
K7m!P9x@QwR3#nB8$vZa
T2d%F6y^Hj4&cN1*sL9(
Passphrase
Generate memorable word-based passphrases:
correct-horse-battery-staple
river-cloud-forest-bridge
ocean-light-storm-bread
Examples
Config: API Key (hex, 64 chars)
Output
Config: Passwords (symbols, 16 chars, 5 count)
Output
Config: Passphrases (memorable, 5 words)
Output
Character Sets
Alphanumeric
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
Hex
Base64
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
Symbols
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{}|;:,.<>?
Passphrase Words
30-word dictionary including: correct, horse, battery, staple, apple, table, river, cloud, stone, forest, bridge, ocean, light, storm, bread, chair, flame, sword, tower, dream, spark, amber, chess, drift, ember, frost, glide, haven, ivory, jewel
Implementation Details
From lib/tools/engine.ts:903-930:
case 'random-string' : {
const ctrl: Record < string , string> = {};
for ( const line of (options.secondInput || '' ). split ( ' \n ' )) {
const eq = line . indexOf ( '=' ); if ( eq > 0 ) ctrl [ line . slice ( 0 , eq ). trim ()] = line . slice ( eq + 1 ). trim ();
}
const length = Math . max ( 1 , Math . min ( 4096 , parseInt ( ctrl . length || '32' )));
const count = Math . max ( 1 , Math . min ( 100 , parseInt ( ctrl . count || '1' )));
const charsets: Record < string , string> = {
default : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ,
hex : '0123456789abcdef' ,
base64 : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' ,
symbols : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{}|;:,.<>?' ,
};
const words = [ 'correct' , 'horse' , 'battery' , 'staple' , 'apple' , 'table' , 'river' , 'cloud' , 'stone' , 'forest' , 'bridge' , 'ocean' , 'light' , 'storm' , 'bread' , 'chair' , 'flame' , 'sword' , 'tower' , 'dream' , 'spark' , 'amber' , 'chess' , 'drift' , 'ember' , 'frost' , 'glide' , 'haven' , 'ivory' , 'jewel' ];
const results: string [] = [];
for ( let i = 0 ; i < count ; i ++ ) {
if ( action === 'passphrase' ) {
const wc = Math . max ( 3 , Math . min ( 12 , Math . round ( length / 6 )));
const arr = new Uint32Array ( wc ); crypto . getRandomValues ( arr );
results . push ( Array . from ( arr ). map (( n ) => words [ n % words . length ]). join ( '-' ));
} else {
const charset = charsets [ action ] ?? charsets . default ;
const arr = new Uint8Array ( length ); crypto . getRandomValues ( arr );
results . push ( Array . from ( arr ). map (( byte ) => charset [ byte % charset . length ]). join ( '' ));
}
}
return { output: results . join ( ' \n ' ), meta: `Mode: ${ action || 'alphanumeric' } | Length: ${ length } | Count: ${ count } ` };
}
All strings are generated using crypto.getRandomValues(), providing cryptographically secure randomness suitable for security-sensitive applications.
For high-security applications (encryption keys, secrets), use dedicated key derivation functions (KDFs) instead of raw random strings.
For passwords, prefer passphrases (4-6 words) over complex character strings. They’re easier to remember and often more secure due to increased entropy.