Skip to content

Instantly share code, notes, and snippets.

@kylemccollom
Created December 17, 2018 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylemccollom/7c3b6c67063af138d7e361329590c36c to your computer and use it in GitHub Desktop.
Save kylemccollom/7c3b6c67063af138d7e361329590c36c to your computer and use it in GitHub Desktop.
// encryption
const padding = calculatePadding(data);
const encryptedMemo = encrypt(data + padding + padding.length, secretKey)
.toString('hex');
const memo = StellarSdk.Memo.hash(encryptedMemo);
// decryption
const decryptedMemo = decrypt(memo.value, secretKey);
const paddingSize = decryptedMemo.last();
const originalData = decryptedMemo.remove(paddingSize + 1);
// remove the padding + the extra character used to store the padding size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment