2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-09-05 08:35:10 +00:00
Files
kdeconnect-android/src/org/kde/kdeconnect/Helpers/RandomHelper.java

23 lines
658 B
Java
Raw Normal View History

2016-02-17 04:48:01 -08:00
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);
}
}