26 lines
551 B
Java
26 lines
551 B
Java
package de.Thiesyy.MelcryptJavaAPI.Util;
|
|
|
|
import java.io.File;
|
|
import java.security.SecureRandom;
|
|
import java.util.Random;
|
|
|
|
|
|
public class KeyGenerator {
|
|
/**
|
|
* Returns a random Key for the Melcrypt Encryption.
|
|
* @return
|
|
*/
|
|
|
|
public static String generateKey() {
|
|
String x = "";
|
|
for(int y = 0; y != 8; y++) {
|
|
int z;
|
|
z = (int) ((new File(".").getUsableSpace() +new SecureRandom().nextInt(24)*4+new SecureRandom().nextInt(10)+System.currentTimeMillis()+new SecureRandom().nextInt())%10);
|
|
if(z==0)z=3;
|
|
x+=z;
|
|
}
|
|
return x;
|
|
}
|
|
}
|
|
|