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); } }
279280281282283284285286287288289
} } } if (configTO.getTransferSettings() == null) { throw new CipherException("Unable to decrypt link."); } } else { logger.log(Level.INFO, " - Link is NOT encrypted. No password needed.");
376377378379380381382383
return repoFileStr; } catch (Exception e) { logger.log(Level.INFO, "Invalid password given, or repo file corrupt.", e); throw new CipherException("Invalid password given, or repo file corrupt.", e); } }