Resolve "Move Hasher and Encryptor to Primitives"

This commit is contained in:
2025-04-07 03:37:43 +00:00
committed by Jim Hamill
parent 653fbffac7
commit 9c7adae7b7
13 changed files with 118 additions and 126 deletions
+74 -2
View File
@@ -4,8 +4,8 @@ import {
Bytes,
encodeExtendedJson,
decodeExtendedJson,
// Encrypter,
// Hasher,
Encrypter,
Hasher,
HDPrivateNode,
HDPublicNode,
Mnemonic,
@@ -204,6 +204,78 @@ export const bytes = {
],
};
export const encrypter = {
from: [
{
label: 'From Passphrase',
inputs: ['Passphrase'],
models: [''],
callback: (args: [string]) => Encrypter.fromPassphrase(...args),
extendedInput: true,
},
],
to: [],
methods: [
{
label: 'Encrypt',
inputs: ['UTF8'],
models: ['Your text here'],
callback: async (encrypter: Encrypter, args: [string]) =>
Bytes.fromBytes(await encrypter.encrypt(...args)).toHex(),
},
{
label: 'Decrypt',
inputs: ['Hex'],
models: ['Encrypted Data (hex)'],
callback: async (encrypter: Encrypter, args: [string]) =>
Bytes.fromBytes(
await encrypter.decrypt(Bytes.fromHex(...args).toBytes()),
).toUtf8(),
},
],
};
export const hasher = {
from: [
{
label: 'From Hex',
inputs: ['Hex'],
models: [''],
callback: (args: [string]) => Hasher.fromHex(...args),
},
{
label: 'From Base64',
inputs: ['Base64'],
models: [''],
callback: (args: [string]) => Hasher.fromBase64(...args),
},
{
label: 'From UTF-8',
inputs: ['UTF-8'],
models: [''],
callback: (args: [string]) => Hasher.fromUTF8(...args),
},
],
to: [
{
label: 'To Sha256 Hex',
callback: (hasher: Hasher) => hasher.toSHA256Hex(),
},
{
label: 'To RipeMD160 Hex',
callback: (hasher: Hasher) => hasher.toRIPEMD160Hex(),
},
{
label: 'To Hash160 Hex',
callback: (hasher: Hasher) => hasher.toHash160Hex(),
},
{
label: 'To Hash256 Hex',
callback: (hasher: Hasher) => hasher.toHash256Hex(),
},
],
};
export const hdPrivateNode = {
from: [
{