· 7 years ago · Dec 17, 2018, 07:10 PM
1// encryption
2const padding = calculatePadding(data);
3const encryptedMemo = encrypt(data + padding + padding.length, secretKey)
4 .toString('hex');
5const memo = StellarSdk.Memo.hash(encryptedMemo);
6
7// decryption
8const decryptedMemo = decrypt(memo.value, secretKey);
9const paddingSize = decryptedMemo.last();
10const originalData = decryptedMemo.remove(paddingSize + 1);
11// remove the padding + the extra character used to store the padding size