Just paste it to a project that supports kotlin language and write a package declaration on the top. Done.
Requires kscript to run as a script:
sdk install kscript
Run:
kscript RandomStringScript.kts
Java UUID's are not secure enough. This class and script do a better job at generating secure random Strings.
Thanks for allow importing files in kotlin scripts: https://github.com/holgerbrandl/kscript
Thanks to this Java RandomString implementation that served as a solid base to build on: https://stackoverflow.com/questions/41107/how-to-generate-a-random-alpha-numeric-string/41156#41156