33343536373839404142
messageDigest.reset(); messageDigest.update(value); return messageDigest.digest(); } catch (Exception e) { throw new CipherException(Convert.toString( "Erro ao codificar, causa [", e.getClass().getSimpleName(), " - ", e.getMessage(), "]"), e); } }
4142434445464748
} } @Override public byte[] decrypt(byte[] value) throws CipherException { throw new CipherException(Convert.toString( "Operacao nao suportada pelo algoritmo [", type.cipher, "]")); }
121314151617181920
class Base64Cipher extends Cipher { @Override public byte[] encrypt(byte[] value) throws CipherException { if (value == null || value.length == 0) { throw new CipherException("Byte array nulo ou invalido"); } return Base64.encode(value).getBytes(); }
202122232425262728
} @Override public byte[] decrypt(byte[] value) throws CipherException { if (value == null || value.length == 0) { throw new CipherException("Byte array nulo ou invalido"); } return Base64.decode(new String(value)); }
394041424344454647
initialize(); cipherAlgorithm.init(javax.crypto.Cipher.ENCRYPT_MODE, secretKey); return cipherAlgorithm.doFinal(value); } catch (Exception e) { throw new CipherException(Convert.toString( "Cipher error: ", e.getMessage()), e); } }
525354555657585960
initialize(); cipherAlgorithm.init(javax.crypto.Cipher.DECRYPT_MODE, secretKey); return cipherAlgorithm.doFinal(value); } catch (Exception e) { throw new CipherException(Convert.toString( "Cipher error: ", e.getMessage()), e); } }