Add missing encoding/decoding helpers in CLI

This commit is contained in:
Simon Warta 2020-02-08 20:14:44 +01:00
parent 266697a63f
commit 295ab8a35c

View File

@ -96,9 +96,14 @@ export function main(originalArgs: readonly string[]): void {
}
}
console.info(colors.yellow(" * helper functions"));
console.info(colors.yellow(" - toAscii"));
console.info(colors.yellow(" - fromAscii"));
console.info(colors.yellow(" - fromBase64"));
console.info(colors.yellow(" - fromHex"));
console.info(colors.yellow(" - fromUtf8"));
console.info(colors.yellow(" - toAscii"));
console.info(colors.yellow(" - toBase64"));
console.info(colors.yellow(" - toHex"));
console.info(colors.yellow(" - toUtf8"));
let init = `
import * as http from 'http';
@ -111,7 +116,7 @@ export function main(originalArgs: readonly string[]): void {
}
// helper functions
init += `
const { toAscii, fromHex, toHex } = Encoding;
const { fromAscii, fromBase64, fromHex, fromUtf8, toAscii, toBase64, toHex, toUtf8 } = Encoding;
`;
if (args.selftest) {
@ -122,6 +127,9 @@ export function main(originalArgs: readonly string[]): void {
const hexHash = toHex(hash);
export class NewDummyClass {};
const encoded = toHex(toUtf8(toBase64(toAscii("hello world"))));
const decoded = fromAscii(fromBase64(fromUtf8(fromHex(encoded))));
const pen = await Secp256k1Pen.fromMnemonic(
"zebra slush diet army arrest purpose hawk source west glimpse custom record",
);