Skip to content

Instantly share code, notes, and snippets.

@bertrand-lupart
Created July 9, 2019 16:25
Show Gist options
  • Save bertrand-lupart/7a7c39dc572fe4d2cbf27b111975c98b to your computer and use it in GitHub Desktop.
Save bertrand-lupart/7a7c39dc572fe4d2cbf27b111975c98b to your computer and use it in GitHub Desktop.
Generate random printable strings using Pike
string random_printable_string(int size)
{
string rand = "";
for(int i=0; i<size; i++)
rand += String.int2char(random(94)+32);
return rand;
}
@bertrand-lupart
Copy link
Author

bertrand-lupart commented Sep 27, 2019

$ ls Rand.pmod
Rand.pmod
$ pike -M .
Pike v8.0 release 702 running Hilfe v3.5 (Incremental Pike Frontend)

string f = Rand.random_printable_string(300); f;
(1) Result: "=PZ\h$MRij+l}lO89#Nv(qs}\"n+QYF4bG=UDg-cuo9iMOTDg(>,-D[pgS )b=s%k\"2$&YjdKQ9v;jd,pRFK.u?:5LD\U5n_T+NsgfEC^uX%c.A\FJB9t/R14J@4dZ)2_t@Cq/}m?'jdlst=A\Z%'1}RIms\,X$g(?.v2mFWtr|9-R{?OF[3@B&kR?j)0Y\?9Ev*k9q)e/3Ip<*sAEvxG8/8v1<QWYesQ<2DH|i_SBEAMG]S=m4#%s8> "zZ'XxR37miF&ld"UIQ+X F3J4,.gJRM&0;kH'[wZm>yfbVE"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment