Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void main(String[] args)throws LoginException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
- String s = "ab";
- Cipher cipher = Cipher.getInstance("AES");
- KeyGenerator kgen = KeyGenerator.getInstance("AES");
- kgen.init(128);
- SecretKey key = kgen.generateKey();
- cipher.init(Cipher.ENCRYPT_MODE,key);
- byte[] bytes = cipher.doFinal(s.getBytes());
- for (byte b : bytes){
- // time.setText(s+" "+ b);
- }
- // String str = new String(bytes, StandardCharsets.UTF_8);
- Cipher decript = Cipher.getInstance("AES");
- decript.init(Cipher.DECRYPT_MODE,key);
- byte[] decriptedBytes = decript.doFinal(bytes);
- for (byte b : decriptedBytes){
- time.setText(String.valueOf((char) b));
- }
- }
Add Comment
Please, Sign In to add comment