I have this Java code to encrypt a data using a key: static String IV = "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"; static String key = "somerandomkey0987"; public static String encrypt(String myData, String key) throws Exception { for(int i = 0; i < myData.length() % 16; ++i) { myData = myData + "\u0000"; } Cipher encripta = Cipher.getInstance("AES/CBC/NoPadding", "SunJCE"); SecretKeySpec key = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); encripta.init(1, key, new IvParameterSpec(IV.getBytes("UTF-8"))); return byteToHex(encripta.doFinal(myData.getBytes("UTF-8"))); } public static String byteToHex(byte[] hash) { Formatter formatter = new Formatter(); byte[] var2 = hash; int var3 = hash.length; for(int var4 = 0; var4 < var3; ++var4) { byte b = var2[var4]; formatter....
A site where you can share knowledge