import { Bytes } from '@xocash/primitives'; import { Encrypter, Hasher } from '@xocash/stack'; 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(), }, ], };