Jump to content

hotpocket

Member
  • Content Count

    3
  • Joined

  • Last visited

About hotpocket

  • Rank
    Newbie

Profile Information

  • Interests
    Chilling in microwave ovens

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi folks, I'm using RippleAPI (the NodeJS library) to write a quick proof-of-concept for an idea I have. Basically what I'm trying to do is store some data in the Memo field. I can do it easily enough with some plain text (e.g., "Here is text" below): const preparedTx = await api.prepareTransaction( { TransactionType: "Payment", Account: ADDRESS, Amount: api.xrpToDrops("22"), // Same as "Amount": "22000000" Destination: "rUCzEr6jrEyMpjhs4wSdQdz4g8Y382NxfM", Memos: [ Memo: { MemoData: Buffer.from("Here is text", "utf8") .toString("hex") .toUpperCase() } } ] }, { // Expire this transaction if it doesn't execute within ~5 minutes: maxLedgerVersionOffset: 5 } ); After submitting the tx I just do this to get the text: let data = tx.specification.memos[0].data; console.log(Buffer.from(data, "hex").toString("utf-8")); // => "Here is text" What I'm having difficulty doing is submitting encrypted data in the memo field, e.g.: const preparedTx = await api.prepareTransaction( { TransactionType: "Payment", Account: ADDRESS, Amount: api.xrpToDrops("22"), // Same as "Amount": "22000000" Destination: "rUCzEr6jrEyMpjhs4wSdQdz4g8Y382NxfM", Memos: [ { Memo: { MemoData: encrypted.toUpperCase() } } ] }, { // Expire this transaction if it doesn't execute within ~5 minutes: maxLedgerVersionOffset: 5 } ); console.log(preparedTx); // => {"TransactionType":"Payment","Account":"rHVQntm23skDRzDrrjtFjr7iWkZvwTPvYd","Amount":"22000000","Destination":"rUCzEr6jrEyMpjhs4wSdQdz4g8Y382NxfM","Memos":[{"Memo":{"MemoData":"EB8C1317FBD61EBF271022486402753A4373E80A6ED498DEB437B27E44E07DB9AC4A8B5BF635E10232A236CE784DCBFC"}}],"Flags":2147483648,"LastLedgerSequence":2617395,"Fee":"12","Sequence":2614128} It looks like the memo field is properly in hex format, but when I print `tx.specification.memos` after submitting the tx, the memo data field looks unrecognizable: [ { data: `�\u0013\u0017��\u001e�'\u0010"Hd\u0002u:Cs�\nnԘ޴7�~D�}��J�[�5�\u00022�6�xM��` } ] How do I fix this to show the hex memo data? (I'm not good with encodings, please forgive me if I'm not using the right terms) Without going too much into the specifics, here is the encryption function: function encrypt(text, secret) { const IV_LENGTH = 16; let iv = crypto.randomBytes(IV_LENGTH); console.log("SECRET_LENGTH", secret.length * 4); let cipher = crypto.createCipheriv( "aes-" + secret.length * 4 + "-cbc", Buffer.from(secret, "hex"), iv ); let encrypted = cipher.update(text); encrypted = Buffer.concat([encrypted, cipher.final()]); return iv.toString("hex") + encrypted.toString("hex"); }
  2. Hello Xrp Chat community! I imagine there are some members who are working on XRP-related projects here and I'm genuinely curious what you're working on (or what you're excited about). I was reviewing the XRP Ledger documentation and I was astonished by the depth of the technology and have been wondering about possibilities of what to build. In a way I'm looking for some inspiration or perhaps a project that I could help out with. Please share what's unique or special about your project
×
×
  • Create New...