mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-05 08:35:10 +00:00
23 lines
658 B
Java
23 lines
658 B
Java
package org.kde.kdeconnect.Helpers;
|
|
|
|
|
|
import java.security.SecureRandom;
|
|
|
|
public class RandomHelper {
|
|
public static SecureRandom secureRandom = new SecureRandom();
|
|
|
|
private static final char[] symbols = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"+
|
|
"abcdefghijklmnopqrstuvwxyz"+
|
|
"1234567890").toCharArray();
|
|
|
|
|
|
public static String randomString(int length) {
|
|
char[] buffer= new char[length];
|
|
for (int idx = 0; idx < length; ++idx) {
|
|
buffer[idx] = symbols[secureRandom.nextInt(symbols.length)];
|
|
}
|
|
return new String(buffer);
|
|
}
|
|
|
|
}
|