public String sign(String message) { return Crypto.sign(message, secret); }
/** * Generate random digital string of random size range from 4 to 12 inclusive * @return a random digital string * @see #genRandomDigits(int) */ public static String genRandomDigits() { SecureRandom random = new SecureRandom(); int n = random.nextInt(8) + 4; return genRandomDigits(n); }
/** * Generate random string with random length from 4 to 12 inclusive * @return the string generated * @see #genRandomStr(int) */ public static String genRandomStr() { SecureRandom random = new SecureRandom(); int len = random.nextInt(12) + 4; return genRandomStr(len); }
/** * This method is deprecated. please use {@link #decryptAES(String, byte[])} instead * * Decrypt a String with the AES encryption standard. Private key must have a length of 16 bytes * * @param value An hexadecimal encrypted string * @param privateKey The key used to encrypt * @return The decrypted String */ @Deprecated public static String decryptAES(String value, String privateKey) { return decryptAES(value, privateKey.getBytes(Charsets.UTF_8)); }
/** * This method is deprecated. Please use {@link #encryptAES(String, byte[])} instead * * Encrypt a String with the AES encryption standard. Private key must have a length of 16 bytes * * @param value The String to encrypt * @param privateKey The key used to encrypt * @return An hexadecimal encrypted string */ @Deprecated public static String encryptAES(String value, String privateKey) { return encryptAES(value, privateKey.getBytes(Charsets.UTF_8)); }
public static char[] generatePassword(int len) { return generatePassword(new char[len]); }
/** * Generate random String with readable characters. This * method will use the {@link SecureRandom} * @param len the size of the string returned * @return the string generated */ public static String genRandomStr(int len) { E.illegalArgumentIf(len < 1); return genRandomX(len, symbols, SYMBOL_SIZE); }
/** * Create a password hash using the default hashing algorithm * * @param input The password * @return The password hash */ public static char[] passwordHash(char[] input) { return passwordHash(input, DEFAULT_HASH_TYPE); }
/** * Generate secret string using 4 bytes * @return the secret */ public static String genSecret() { return genSecret(4); }
/** * This method is deprecated. please use {@link #decryptAES(String, byte[])} instead * * Decrypt a String with the AES encryption standard. Private key must have a length of 16 bytes * * @param value An hexadecimal encrypted string * @param privateKey The key used to encrypt * @return The decrypted String */ @Deprecated public static String decryptAES(String value, String privateKey) { return decryptAES(value, privateKey.getBytes(Charsets.UTF_8)); }
/** * This method is deprecated. Please use {@link #encryptAES(String, byte[])} instead * * Encrypt a String with the AES encryption standard. Private key must have a length of 16 bytes * * @param value The String to encrypt * @param privateKey The key used to encrypt * @return An hexadecimal encrypted string */ @Deprecated public static String encryptAES(String value, String privateKey) { return encryptAES(value, privateKey.getBytes(Charsets.UTF_8)); }
public static char[] generatePassword() { return generatePassword(null); }
/** * Generate random String with readable characters. This * method will use the {@link SecureRandom} * @param len the size of the string returned * @return the string generated */ public static String genRandomStr(int len) { E.illegalArgumentIf(len < 1); return genRandomX(len, symbols, SYMBOL_SIZE); }
/** * Create a password hash using the default hashing algorithm * * @param input The password * @return The password hash */ public static String passwordHash(String input) { return passwordHash(input, DEFAULT_HASH_TYPE); }
/** * Generate secret string using 4 bytes * @return the secret */ public static String genSecret() { return genSecret(4); }
/** * This method is deprecated. please use {@link #decryptAES(String, byte[], byte[])} instead * * Decrypt a String with the AES encryption standard. Private key must have a length of 16 bytes * * @param value An hexadecimal encrypted string * @param privateKey The key used to encrypt * @param salt the salt * @return The decrypted String */ @Deprecated public static String decryptAES(String value, String privateKey, String salt) { return decryptAES(value, privateKey.getBytes(Charsets.UTF_8), salt.getBytes(Charsets.UTF_8)); }
/** * This method is deprecated, please use {@link #encryptAES(String, byte[])} instead * * Encrypt a String with the AES encryption standard. Private key must have a length of 16 bytes * * @param value The String to encrypt * @param privateKey The key used to encrypt * @param salt The salt * @return An hexadecimal encrypted string */ @Deprecated public static String encryptAES(String value, String privateKey, String salt) { return encryptAES(value, privateKey.getBytes(Charsets.UTF_8), salt.getBytes(Charsets.UTF_8)); }
public String sign(String message) { return Crypto.sign(message, secret); }
public static char[] generatePassword(int len) { return generatePassword(new char[len]); }
/** * Generate random digital string with the size specified. The * method use the {@link SecureRandom} * @param len the number of digits in the string generated * @return a string contains random digits */ public static String genRandomDigits(int len) { E.illegalArgumentIf(len < 1); if (len < 10) { SecureRandom random = new SecureRandom(); int n = random.nextInt(POWER_OF_TEN[len]); int base = POWER_OF_TEN[len - 1]; if (n < base) { n += base; } return String.valueOf(n); } else { return genRandomX(len, digits, DIGITS_SIZE); } }