UNPKG

@signumjs/crypto

Version:

Cryptographic functions for building Signum Network apps.

50 lines (49 loc) 1.58 kB
/** * Original work Copyright (c) 2024 Signum Network */ export type InputEncoding = 'utf8' | 'hex' | 'base64'; /** * Hash string into raw array buffer * @param input An arbitrary text * @param encoding The encoding of input type (default: 'utf8') * @return the hash for that string in ArrayBuffer * * @category sha256 */ export declare function sha256Raw(input: string, encoding: InputEncoding): ArrayBuffer; /** * Hash string into byte array * @param input An arbitrary text * @param encoding The encoding of input type (default: 'utf8') * @return the hash for that string in Uint8Array * * * @category sha256 */ export declare function sha256AsBytes(input: string, encoding?: InputEncoding): Uint8Array; /** * Hash string into hex string * @param input An arbitrary text (utf-8) * @param encoding The encoding of input type (default: 'utf8') * @return the hash for that string in hex format * * @category sha256 */ export declare function sha256AsHex(input: string, encoding?: InputEncoding): string; /** * Hash string into base64 string * @param input An arbitrary text (utf-8) * @param encoding The encoding of input type (default: 'utf8') * @return the hash for that string in base64 format * * @category sha256 */ export declare function sha256AsBase64(input: string, encoding?: InputEncoding): string; /** * Hashes binary data into byte array * @param data A hex data string or byte array * @return the hash for that as byte array * * @category sha256 */ export declare function sha256Binary(data: string | Uint8Array): Uint8Array;