/** * 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 #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 #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 #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)); }
public String decrypt(String message) { try { return Crypto.decryptAES(message, secret); } catch (UnexpectedException e) { Throwable cause = e.getCause(); if (cause instanceof InvalidKeyException) { LOGGER.error("Cannot encrypt/decrypt! Please download Java Crypto Extension pack from Oracle: http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html"); } throw e; } }
public String decrypt(String message) { try { return Crypto.decryptAES(message, secret); } catch (UnexpectedException e) { Throwable cause = e.getCause(); if (cause instanceof InvalidKeyException) { LOGGER.error("Cannot encrypt/decrypt! Please download Java Crypto Extension pack from Oracle: http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html"); } throw e; } }
/** * Check if a string is a valid token * @param secret the secret to decrypt the string * @param oid the ID supposed to be encapsulated in the token * @param token the token string * @return {@code true} if the token is valid */ @SuppressWarnings("unused") public static boolean isTokenValid(byte[] secret, String oid, String token) { if (S.anyBlank(oid, token)) { return false; } String s = Crypto.decryptAES(token, secret); String[] sa = s.split("\\|"); if (sa.length < 2) return false; if (!S.isEqual(oid, sa[0])) return false; try { long due = Long.parseLong(sa[1]); return (due < 1 || due > System.currentTimeMillis()); } catch (Exception e) { return false; } }
String s = ""; try { s = Crypto.decryptAES(token, secret); } catch (Exception e) { return tk;