My back end in Spring after a transaction must send a link to a user with some metadata encrypted and put in url in order to open directly the app when the user click on it.
My code is this:
String id = "5d2583a5-2f0e-4660-95fe-7775e9660c9a";
Map<String, String> data = new HashMap<>();
data.put("id", id);
data.put("status", "SUCCESSFUL");
data.put("type", "apk");
//convert to json string
String jsonString = new Gson().toJson(data);
System.out.println(jsonString);
AES256TextEncryptor textEncryptor = new AES256TextEncryptor();
textEncryptor.setPassword(id);
String myEncryptedText = textEncryptor.encrypt(jsonString);
System.out.println(myEncryptedText);
//we try to short the data and send it => impossible to revert the myEncryptedText => we want to change this part
String sha256hex = Hashing.sha1()
.hashString(myEncryptedText, StandardCharsets.UTF_8)
.toString();
Assert.assertEquals("we should have ", 40, sha256hex.length());
System.out.println(sha256hex);
The first encrypted value with myEncryptedText returns a long string
eX8H14Gg1detgGb97ZWF0cIHz7LTxKeLynuZC1Dok7Zl5jTeLMcEulFroD0MZ2xVyc87ETORtoKGmuLl2AwdPKp90DTWbV9uoQJZkBIWlvOb5O/9M+WZg83wP5KjqtRh1AKLAgSoWWG2IzwBkWE4QV4/bUmTlDmXLzYD8z6/Txg= b86e21d1117ea756b5c8b4da3fc0feb61b6d68fa
I tried to use sha1, to make it shorter but we notice that it is impossible to revert it in the 2nd app, so we are looking for another solution to short to max 50 characters the myEncryptedText, and get the full character on the client side.
How could we do it easily ? Thanks