My Java portion for M2. String randomizing method.