Skip to content

Instantly share code, notes, and snippets.

@TLMcode
Last active December 20, 2015 21:39
Show Gist options
  • Save TLMcode/6198870 to your computer and use it in GitHub Desktop.
Save TLMcode/6198870 to your computer and use it in GitHub Desktop.
GenRndStr()
F1::MsgBox % GenRndStr( 10 )
Return
GenRndStr( len )
{
loop % (122, d="~")
cStr .= chr( (i:=a_index)>32&&i<60 ? i : i>59&&i<91 ? i : i>93&&i<125 ? i : "" ) d
cStr:=regexreplace(cStr, d d)
while ( strlen(nStr)<len )
{
sort, cStr, % "Random D" d
nStr .= ((v:=substr(regexreplace(cStr,d),1,10))~="\d"
&&v~="[!-/]"&&v~="[:-@]"&&v~="[^-`]"&&v~="[A-Z]"&&v~="[a-z]"
&&!(v~="[A-Z]{2}")&&!(v~="[a-z]{2}")&&!(v~="\d{2}")) ? v : ""
}
return substr(nStr,1,len)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment