I have an mobile app and a desktop app.I have multiple list in desktop app. I want to encrypt all the values in the lists and send to a file and later from the mobile app i want retrieve the data from the file and decrypt the values and display them. I am using the encryption and decryption concept for the first time.I tried sending a string by encrypting and it worked.But i want to encrypt many list . How will i do that.Any code will be helpful.
For encrypting:
KeyGenerator keygenerator = KeyGenerator.getInstance("DES");
SecretKey myDesKey = keygenerator.generateKey();
Cipher desCipher;
desCipher = Cipher.getInstance("DES");
byte[] text = "Hello".getBytes("UTF8");
desCipher.init(Cipher.ENCRYPT_MODE, myDesKey);
byte[] textEncrypted = desCipher.doFinal(text);
String s = new String(textEncrypted);
System.out.println(s);
For Decrpyting
desCipher.init(Cipher.DECRYPT_MODE, myDesKey);
byte[] textDecrypted = desCipher.doFinal(textEncrypted);
s = new String(textDecrypted);
System.out.println(s);
I used this code for a string but How to achieve the same with the list.Please help.
Thanks in advance.