Guest User

Untitled

a guest
Jul 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. private byte[] encrypt(String password) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
  2. Cipher cipher = Cipher.getInstance("AES");
  3. SecretKeySpec secretKey = new SecretKeySpec("dfgkirvbn25685la".getBytes(), "AES");
  4. cipher.init(Cipher.ENCRYPT_MODE, secretKey);
  5. return cipher.doFinal(password.getBytes());
  6. }
  7.  
  8. private String decrypt(PersonEntity pe) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
  9. Cipher cipher = Cipher.getInstance("AES");
  10. SecretKeySpec secretKey = new SecretKeySpec("dfgkirvbn25685la".getBytes(), "AES");
  11. cipher.init(Cipher.DECRYPT_MODE, secretKey);
  12. String s = "";
  13. byte[] bites = cipher.doFinal(pe.getPassword());
  14. for (byte b : bites) {
  15. s += (char) b;
  16. }
  17. return s;
  18. }
Add Comment
Please, Sign In to add comment