@push.rocks/smarthash
Version:
Cross-environment hash functions (SHA256 and MD5) for Node.js and browsers, with support for strings, streams, and files.
33 lines (32 loc) • 1.11 kB
TypeScript
/**
* Computes sha256 Hash from String
*/
export declare const sha256FromString: (stringArg: string) => Promise<string>;
/**
* Computes sha256 Hash from String synchronously
* Note: In browser environment, this is still async internally but we maintain the API
*/
export declare const sha256FromStringSync: (stringArg: string) => string;
/**
* Computes sha256 Hash from ArrayBuffer
*/
export declare const sha256FromBuffer: (bufferArg: ArrayBuffer | Uint8Array) => Promise<string>;
/**
* computes sha265 Hash from Object
*/
export declare const sha265FromObject: (objectArg: any) => Promise<string>;
/**
* creates sha256 Hash from Stream
* Note: Not supported in browser environment
*/
export declare const sha256FromStream: (input: any) => Promise<string>;
/**
* creates sha256 Hash from File
* Note: Not supported in browser environment
*/
export declare const sha256FromFile: (filePath: string) => Promise<string>;
/**
* Computes MD5 Hash from String
* Note: MD5 is not natively supported by Web Crypto API
*/
export declare const md5FromString: (stringToHash: string) => Promise<string>;