Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private byte[] encrypt(String password) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
- Cipher cipher = Cipher.getInstance("AES");
- SecretKeySpec secretKey = new SecretKeySpec("dfgkirvbn25685la".getBytes(), "AES");
- cipher.init(Cipher.ENCRYPT_MODE, secretKey);
- return cipher.doFinal(password.getBytes());
- }
- private String decrypt(PersonEntity pe) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
- Cipher cipher = Cipher.getInstance("AES");
- SecretKeySpec secretKey = new SecretKeySpec("dfgkirvbn25685la".getBytes(), "AES");
- cipher.init(Cipher.DECRYPT_MODE, secretKey);
- String s = "";
- byte[] bites = cipher.doFinal(pe.getPassword());
- for (byte b : bites) {
- s += (char) b;
- }
- return s;
- }
Add Comment
Please, Sign In to add comment