public String createEncryptedLink(SaltedSecretKey masterKey) throws Exception {
byte[] plaintextStorageXml = getPlaintextStorageXml();
List<CipherSpec> cipherSpecs = CipherSpecs.getDefaultCipherSpecs();
byte[] masterKeySalt = masterKey.getSalt();
byte[] encryptedPluginBytes = CipherUtil.encrypt(new ByteArrayInputStream(plaintextStorageXml), cipherSpecs, masterKey);
String masterKeySaltEncodedStr = Base58.encode(masterKeySalt);
String encryptedEncodedPlugin = Base58.encode(encryptedPluginBytes);
String applicationLink = String.format(LINK_FORMAT_ENCRYPTED, masterKeySaltEncodedStr, encryptedEncodedPlugin);
if (shortUrl) {
return shortenLink(applicationLink);
}
else {
return applicationLink;
}
}