Version: v0.6.1 - Beta.  We welcome contributors & feedback.  THanks!

String.random

String.random($length, $safeCharsOnly = false)

Description

Generate a string composed of random base64 characters.

If $safeCharsOnly is true, the + and / characters will be replaced with ~ and _ respectively. These will be suitable for filepaths and URLs without extra escaping.

String.random(20);
//= '3xpOyFxyx/MypO+YfBf1'

String.random(20, true);
//= 'DW7E0YAf_bcVvcfs~uZ'