This repository has been archived on 2022-06-13. You can view files and clone it, but cannot push or open issues or pull requests.
waifu2xlemon/src/main/java/moe/lemonsh/waifu2xlemon/AccessTokenGenerator.java
2021-08-20 20:00:29 +02:00

14 lines
528 B
Java

package moe.lemonsh.waifu2xlemon;
import java.util.Random;
public class AccessTokenGenerator {
private static final char[] allowedCharacters = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890".toCharArray();
private static final Random rng = new Random();
public static String randomToken(int length) {
var token = new char[length];
for (int i = 0; i < token.length; i++) token[i] = allowedCharacters[rng.nextInt(allowedCharacters.length)];
return new String(token);
}
}