Appearance
Encrypt a String, Salt Generation and Fetch Transaction Memo
To encrypt a string, generate a salt, and get a transaction memo using the skc-trade-sdk
, you can follow these steps:
Encrypting a String:
- Use the
encrypt
function from theskc-trade-sdk
to encrypt a plaintext message using the public key of the counterparty.
javascript
import { encrypt } from "skc-trade-sdk";
const encryptedMessage = await encrypt("This is a secret message", "0xCounterPartyPublicKey");
Generating a Salt:
- Use the
generateSalt
function from theutils
module of theskc-trade-sdk
to generate a SHA-256 hash of the input string.
javascript
import { utils } from "skc-trade-sdk";
const salt = await utils.generateSalt("your-input-string");
Getting a Transaction Memo:
- Use the
getTxMemo
method from theTradeCms
class to fetch the memo of a transaction using its hash.
javascript
import { TradeCms } from "skc-trade-sdk";
const cms = new TradeCms("https://example.com");
const txMemo = await cms.getTxMemo("transaction-hash");
By following these steps, you can encrypt a string, generate a salt, and retrieve a transaction memo using the skc-trade-sdk
.