richard.herbert
02/22/2023, 7:09 PMbdw429s
02/22/2023, 7:11 PMbdw429s
02/22/2023, 7:11 PMrichard.herbert
02/22/2023, 7:12 PMbdw429s
02/22/2023, 7:12 PMbdw429s
02/22/2023, 7:13 PMbdw429s
02/22/2023, 7:13 PMrichard.herbert
02/22/2023, 7:14 PMScott Bennett
02/22/2023, 7:15 PMScott Bennett
02/22/2023, 7:16 PMScott Bennett
02/22/2023, 7:18 PMScott Bennett
02/22/2023, 7:19 PM<cfscript>
function RandomString(length, chars="ABCDEFGHIJKLMNOPQRST0123456789-") {
var i = 0;
var theString = "";
for (i = 0; i < length; i++) {
theString &= Mid(chars, RandRange(1, len(chars), "SHA1PRNG"), 1);
}
return theString;
}
</cfscript>
(which I copied from https://lunaticthinker.me/index.php/cfml-generating-random-string/)bdw429s
02/22/2023, 7:19 PMbdw429s
02/22/2023, 7:19 PMScott Bennett
02/22/2023, 7:22 PMScott Bennett
02/22/2023, 7:23 PMrichard.herbert
02/22/2023, 7:24 PMcsrfGenerateToken() , thanks.bdw429s
02/22/2023, 7:28 PMpublic static String createRandomStringLC(int length) {
if (length < 1) return "";
SecureRandom sr = new SecureRandom();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++) {
int rnd = (int) (sr.nextDouble() * (CHARS_LC.length - 1));
sb.append(CHARS_LC[rnd]);
}
return sb.toString();
}
where CHARS_LC is an array of lower case letters and the length is 40bdw429s
02/22/2023, 7:28 PMScott Bennett
02/22/2023, 7:28 PMcsrfGenerateToken() to prevent cross site request forgery but I have used it for other things, like generating a token for forgot password links that get emailed to users and stuff like that.bdw429s
02/22/2023, 7:28 PMbdw429s
02/22/2023, 7:28 PMbdw429s
02/22/2023, 7:29 PMRandomUtil.java class on line 42richard.herbert
02/22/2023, 7:33 PMEvil Ware
02/22/2023, 7:37 PMrichard.herbert
02/22/2023, 7:39 PMbdw429s
02/22/2023, 7:39 PMbdw429s
02/22/2023, 7:39 PMbdw429s
02/22/2023, 7:40 PMbdw429s
02/22/2023, 7:40 PMrichard.herbert
02/22/2023, 7:40 PMbdw429s
02/22/2023, 7:41 PMbdw429s
02/22/2023, 7:41 PMbdw429s
02/22/2023, 7:41 PMbdw429s
02/22/2023, 7:42 PMEvil Ware
02/22/2023, 7:44 PMbdw429s
02/22/2023, 7:44 PMEvil Ware
02/22/2023, 7:45 PMEvil Ware
02/22/2023, 7:45 PMbdw429s
02/22/2023, 7:45 PMEvil Ware
02/22/2023, 7:45 PMbdw429s
02/22/2023, 7:45 PMEvil Ware
02/22/2023, 7:45 PMEvil Ware
02/22/2023, 7:46 PMbdw429s
02/22/2023, 7:48 PMbdw429s
02/22/2023, 7:49 PMjava.util.RandomEvil Ware
02/22/2023, 7:49 PMbdw429s
02/22/2023, 7:50 PMbdw429s
02/22/2023, 7:50 PMEvil Ware
02/22/2023, 7:51 PMEvil Ware
02/22/2023, 7:55 PMEvil Ware
02/22/2023, 7:59 PM