Amend Primitives/Tooling
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import { Bytes } from '@xocash/primitives';
|
||||
import { Encrypter, Hasher } from '@xocash/stack';
|
||||
|
||||
import { Encryption } from '@xocash/stack';
|
||||
|
||||
export const encryption = {
|
||||
export const encrypter = {
|
||||
from: [
|
||||
{
|
||||
label: 'From Passphrase',
|
||||
inputs: ['Passphrase'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => Encryption.fromPassphrase(...args),
|
||||
callback: (args: [string]) => Encrypter.fromPassphrase(...args),
|
||||
extendedInput: true,
|
||||
},
|
||||
],
|
||||
@@ -18,17 +17,58 @@ export const encryption = {
|
||||
label: 'Encrypt',
|
||||
inputs: ['UTF8'],
|
||||
models: ['Your text here'],
|
||||
callback: async (encryption: Encryption, args: [string]) =>
|
||||
Bytes.fromBytes(await encryption.encrypt(...args)).toHex(),
|
||||
callback: async (encrypter: Encrypter, args: [string]) =>
|
||||
Bytes.fromBytes(await encrypter.encrypt(...args)).toHex(),
|
||||
},
|
||||
{
|
||||
label: 'Decrypt',
|
||||
inputs: ['Hex'],
|
||||
models: ['Encrypted Data (hex)'],
|
||||
callback: async (encryption: Encryption, args: [string]) =>
|
||||
callback: async (encrypter: Encrypter, args: [string]) =>
|
||||
Bytes.fromBytes(
|
||||
await encryption.decrypt(Bytes.fromHex(...args).toBytes()),
|
||||
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(),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user