/** * Decrpyt the encrypted text. * * @param encryptedText Encrypted text * @return Plain text */ public static String decryptString(String encryptedText) { if (encryptedText == null || encryptedText.length() == 0) { return encryptedText; } TEAV tea = getTEA(); int[] encBytes = tea.hexToBin(encryptedText); byte[] rawBytes = tea.decode(encBytes); return new String(rawBytes).trim(); }
/** * Encrypt the specified plaintext. * * @param plaintext Plain text string. * @return Encrypted text */ public static String encryptString(String plaintext) { if (plaintext == null || plaintext.length() == 0) { return plaintext; } TEAV tea = getTEA(); String padStr = tea.padPlaintext(plaintext); byte[] plainBytes = padStr.getBytes(); int[] encBytes = tea.encode(plainBytes, plainBytes.length); return tea.binToHex(encBytes); }