feat: Replace aCAPTCHA with official ALTCHA (altcha.org) Proof-of-Work web component widget
This commit is contained in:
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* hash-wasm (https://www.npmjs.com/package/hash-wasm)
|
||||
* (c) Dani Biro
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).hashwasm=e.hashwasm||{})}(this,(function(e){"use strict";var t;const n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,r=null!==(t=n.Buffer)&&void 0!==t?t:null,i=n.TextEncoder?new n.TextEncoder:null,f=null!==r?e=>{if("string"==typeof e){const t=r.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(r.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return i.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=new Uint8Array(256);for(let e=0;e<o.length;e++)s[o.charCodeAt(e)]=e;function a(e,t){e.init();const{blockSize:n}=e,r=function(e,t){const{blockSize:n}=e,r=f(t);if(r.length>n){e.update(r);const t=e.digest("binary");return e.init(),t}return new Uint8Array(r.buffer,r.byteOffset,r.length)}(e,t),i=new Uint8Array(n);i.set(r);const o=new Uint8Array(n);for(let e=0;e<n;e++){const t=i[e];o[e]=92^t,i[e]=54^t}e.update(i);const s={init:()=>(e.init(),e.update(i),s),update:t=>(e.update(t),s),digest:t=>{const n=e.digest("binary");return e.init(),e.update(o),e.update(n),e.digest(t)},save:()=>{throw new Error("save() not supported")},load:()=>{throw new Error("load() not supported")},blockSize:e.blockSize,digestSize:e.digestSize};return s}e.createHMAC=function(e,t){if(!e||!e.then)throw new Error('Invalid hash function is provided! Usage: createHMAC(createMD5(), "key").');return e.then((e=>a(e,t)))}}));
|
||||
+2671
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+2731
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+60
@@ -0,0 +1,60 @@
|
||||
import { type IDataType, type IEmbeddedWasm } from "./util";
|
||||
export declare const MAX_HEAP: number;
|
||||
type ThenArg<T> = T extends Promise<infer U> ? U : T extends (...args: any[]) => Promise<infer V> ? V : T;
|
||||
export type IHasher = {
|
||||
/**
|
||||
* Initializes hash state to default value
|
||||
*/
|
||||
init: () => IHasher;
|
||||
/**
|
||||
* Updates the hash content with the given data
|
||||
*/
|
||||
update: (data: IDataType) => IHasher;
|
||||
/**
|
||||
* Calculates the hash of all of the data passed to be hashed with hash.update().
|
||||
* Defaults to hexadecimal string
|
||||
* @param outputType If outputType is "binary", it returns Uint8Array. Otherwise it
|
||||
* returns hexadecimal string
|
||||
*/
|
||||
digest: {
|
||||
(outputType: "binary"): Uint8Array;
|
||||
(outputType?: "hex"): string;
|
||||
};
|
||||
/**
|
||||
* Save the current internal state of the hasher for later resumption with load().
|
||||
* Cannot be called before .init() or after .digest()
|
||||
*
|
||||
* Note that this state can include arbitrary information about the value being hashed (e.g.
|
||||
* could include N plaintext bytes from the value), so needs to be treated as being as
|
||||
* sensitive as the input value itself.
|
||||
*/
|
||||
save: () => Uint8Array;
|
||||
/**
|
||||
* Resume a state that was created by save(). If this state was not created by a
|
||||
* compatible build of hash-wasm, an exception will be thrown.
|
||||
*/
|
||||
load: (state: Uint8Array) => IHasher;
|
||||
/**
|
||||
* Block size in bytes
|
||||
*/
|
||||
blockSize: number;
|
||||
/**
|
||||
* Digest size in bytes
|
||||
*/
|
||||
digestSize: number;
|
||||
};
|
||||
export declare function WASMInterface(binary: IEmbeddedWasm, hashLength: number): Promise<{
|
||||
getMemory: () => Uint8Array;
|
||||
writeMemory: (data: Uint8Array, offset?: number) => void;
|
||||
getExports: () => any;
|
||||
setMemorySize: (totalSize: number) => void;
|
||||
init: (bits?: number) => void;
|
||||
update: (data: IDataType) => void;
|
||||
digest: (outputType: "hex" | "binary", padding?: number) => Uint8Array | string;
|
||||
save: () => Uint8Array;
|
||||
load: (state: Uint8Array) => void;
|
||||
calculate: (data: IDataType, initParam?: any, digestParam?: any) => string;
|
||||
hashLength: number;
|
||||
}>;
|
||||
export type IWASMInterface = ThenArg<ReturnType<typeof WASMInterface>>;
|
||||
export {};
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates Adler-32 hash. The resulting 32-bit hash is stored in
|
||||
* network byte order (big-endian).
|
||||
*
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function adler32(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new Adler-32 hash instance
|
||||
*/
|
||||
export declare function createAdler32(): Promise<IHasher>;
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
import { type IDataType } from "./util";
|
||||
export interface IArgon2Options {
|
||||
/**
|
||||
* Password (or message) to be hashed
|
||||
*/
|
||||
password: IDataType;
|
||||
/**
|
||||
* Salt (usually containing random bytes)
|
||||
*/
|
||||
salt: IDataType;
|
||||
/**
|
||||
* Secret for keyed hashing
|
||||
*/
|
||||
secret?: IDataType;
|
||||
/**
|
||||
* Number of iterations to perform
|
||||
*/
|
||||
iterations: number;
|
||||
/**
|
||||
* Degree of parallelism
|
||||
*/
|
||||
parallelism: number;
|
||||
/**
|
||||
* Amount of memory to be used in kibibytes (1024 bytes)
|
||||
*/
|
||||
memorySize: number;
|
||||
/**
|
||||
* Output size in bytes
|
||||
*/
|
||||
hashLength: number;
|
||||
/**
|
||||
* Desired output type. Defaults to 'hex'
|
||||
*/
|
||||
outputType?: "hex" | "binary" | "encoded";
|
||||
}
|
||||
interface IArgon2OptionsBinary {
|
||||
outputType: "binary";
|
||||
}
|
||||
type Argon2ReturnType<T> = T extends IArgon2OptionsBinary ? Uint8Array : string;
|
||||
/**
|
||||
* Calculates hash using the argon2i password-hashing function
|
||||
* @returns Computed hash
|
||||
*/
|
||||
export declare function argon2i<T extends IArgon2Options>(options: T): Promise<Argon2ReturnType<T>>;
|
||||
/**
|
||||
* Calculates hash using the argon2id password-hashing function
|
||||
* @returns Computed hash
|
||||
*/
|
||||
export declare function argon2id<T extends IArgon2Options>(options: T): Promise<Argon2ReturnType<T>>;
|
||||
/**
|
||||
* Calculates hash using the argon2d password-hashing function
|
||||
* @returns Computed hash
|
||||
*/
|
||||
export declare function argon2d<T extends IArgon2Options>(options: T): Promise<Argon2ReturnType<T>>;
|
||||
export interface Argon2VerifyOptions {
|
||||
/**
|
||||
* Password to be verified
|
||||
*/
|
||||
password: IDataType;
|
||||
/**
|
||||
* Secret used on hash creation
|
||||
*/
|
||||
secret?: IDataType;
|
||||
/**
|
||||
* A previously generated argon2 hash in the 'encoded' output format
|
||||
*/
|
||||
hash: string;
|
||||
}
|
||||
/**
|
||||
* Verifies password using the argon2 password-hashing function
|
||||
* @returns True if the encoded hash matches the password
|
||||
*/
|
||||
export declare function argon2Verify(options: Argon2VerifyOptions): Promise<boolean>;
|
||||
export {};
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
import { type IDataType } from "./util";
|
||||
export interface BcryptOptions {
|
||||
/**
|
||||
* Password to be hashed
|
||||
*/
|
||||
password: IDataType;
|
||||
/**
|
||||
* Salt (16 bytes long - usually containing random bytes)
|
||||
*/
|
||||
salt: IDataType;
|
||||
/**
|
||||
* Number of iterations to perform (4 - 31)
|
||||
*/
|
||||
costFactor: number;
|
||||
/**
|
||||
* Desired output type. Defaults to 'encoded'
|
||||
*/
|
||||
outputType?: "hex" | "binary" | "encoded";
|
||||
}
|
||||
interface IBcryptOptionsBinary {
|
||||
outputType: "binary";
|
||||
}
|
||||
type BcryptReturnType<T> = T extends IBcryptOptionsBinary ? Uint8Array : string;
|
||||
/**
|
||||
* Calculates hash using the bcrypt password-hashing function
|
||||
* @returns Computed hash
|
||||
*/
|
||||
export declare function bcrypt<T extends BcryptOptions>(options: T): Promise<BcryptReturnType<T>>;
|
||||
export interface BcryptVerifyOptions {
|
||||
/**
|
||||
* Password to be verified
|
||||
*/
|
||||
password: IDataType;
|
||||
/**
|
||||
* A previously generated bcrypt hash in the 'encoded' output format
|
||||
*/
|
||||
hash: string;
|
||||
}
|
||||
/**
|
||||
* Verifies password using bcrypt password-hashing function
|
||||
* @returns True if the encoded hash matches the password
|
||||
*/
|
||||
export declare function bcryptVerify(options: BcryptVerifyOptions): Promise<boolean>;
|
||||
export {};
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import { type IDataType } from "./util";
|
||||
/**
|
||||
* Calculates BLAKE2b hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param bits Number of output bits, which has to be a number
|
||||
* divisible by 8, between 8 and 512. Defaults to 512.
|
||||
* @param key Optional key (string, Buffer or TypedArray). Maximum length is 64 bytes.
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function blake2b(data: IDataType, bits?: number, key?: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new BLAKE2b hash instance
|
||||
* @param bits Number of output bits, which has to be a number
|
||||
* divisible by 8, between 8 and 512. Defaults to 512.
|
||||
* @param key Optional key (string, Buffer or TypedArray). Maximum length is 64 bytes.
|
||||
*/
|
||||
export declare function createBLAKE2b(bits?: number, key?: IDataType): Promise<IHasher>;
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import { type IDataType } from "./util";
|
||||
/**
|
||||
* Calculates BLAKE2s hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param bits Number of output bits, which has to be a number
|
||||
* divisible by 8, between 8 and 256. Defaults to 256.
|
||||
* @param key Optional key (string, Buffer or TypedArray). Maximum length is 32 bytes.
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function blake2s(data: IDataType, bits?: number, key?: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new BLAKE2s hash instance
|
||||
* @param bits Number of output bits, which has to be a number
|
||||
* divisible by 8, between 8 and 256. Defaults to 256.
|
||||
* @param key Optional key (string, Buffer or TypedArray). Maximum length is 32 bytes.
|
||||
*/
|
||||
export declare function createBLAKE2s(bits?: number, key?: IDataType): Promise<IHasher>;
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import { type IDataType } from "./util";
|
||||
/**
|
||||
* Calculates BLAKE3 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param bits Number of output bits, which has to be a number
|
||||
* divisible by 8. Defaults to 256.
|
||||
* @param key Optional key (string, Buffer or TypedArray). Length should be 32 bytes.
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function blake3(data: IDataType, bits?: number, key?: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new BLAKE3 hash instance
|
||||
* @param bits Number of output bits, which has to be a number
|
||||
* divisible by 8. Defaults to 256.
|
||||
* @param key Optional key (string, Buffer or TypedArray). Length should be 32 bytes.
|
||||
*/
|
||||
export declare function createBLAKE3(bits?: number, key?: IDataType): Promise<IHasher>;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates CRC-32 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param polynomial Input polynomial (defaults to 0xedb88320, for CRC32C use 0x82f63b78)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function crc32(data: IDataType, polynomial?: number): Promise<string>;
|
||||
/**
|
||||
* Creates a new CRC-32 hash instance
|
||||
* @param polynomial Input polynomial (defaults to 0xedb88320, for CRC32C use 0x82f63b78)
|
||||
*/
|
||||
export declare function createCRC32(polynomial?: number): Promise<IHasher>;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates CRC-64 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param polynomial Input polynomial (defaults to 'c96c5795d7870f42' - ECMA)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function crc64(data: IDataType, polynomial?: string): Promise<string>;
|
||||
/**
|
||||
* Creates a new CRC-64 hash instance
|
||||
* @param polynomial Input polynomial (defaults to 'c96c5795d7870f42' - ECMA)
|
||||
*/
|
||||
export declare function createCRC64(polynomial?: string): Promise<IHasher>;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import type { IHasher } from "./WASMInterface";
|
||||
import { type IDataType } from "./util";
|
||||
/**
|
||||
* Calculates HMAC hash
|
||||
* @param hash Hash algorithm to use. It has to be the return value of a function like createSHA1()
|
||||
* @param key Key (string, Buffer or TypedArray)
|
||||
*/
|
||||
export declare function createHMAC(hash: Promise<IHasher>, key: IDataType): Promise<IHasher>;
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
export * from "./adler32";
|
||||
export * from "./argon2";
|
||||
export * from "./blake2b";
|
||||
export * from "./blake2s";
|
||||
export * from "./blake3";
|
||||
export * from "./crc32";
|
||||
export * from "./crc64";
|
||||
export * from "./md4";
|
||||
export * from "./md5";
|
||||
export * from "./sha1";
|
||||
export * from "./sha3";
|
||||
export * from "./keccak";
|
||||
export * from "./sha224";
|
||||
export * from "./sha256";
|
||||
export * from "./sha384";
|
||||
export * from "./sha512";
|
||||
export * from "./xxhash32";
|
||||
export * from "./xxhash64";
|
||||
export * from "./xxhash3";
|
||||
export * from "./xxhash128";
|
||||
export * from "./ripemd160";
|
||||
export * from "./hmac";
|
||||
export * from "./pbkdf2";
|
||||
export * from "./scrypt";
|
||||
export * from "./bcrypt";
|
||||
export * from "./whirlpool";
|
||||
export * from "./sm3";
|
||||
export type { IDataType } from "./util";
|
||||
export type { IHasher } from "./WASMInterface";
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
type IValidBits = 224 | 256 | 384 | 512;
|
||||
/**
|
||||
* Calculates Keccak hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param bits Number of output bits. Valid values: 224, 256, 384, 512
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function keccak(data: IDataType, bits?: IValidBits): Promise<string>;
|
||||
/**
|
||||
* Creates a new Keccak hash instance
|
||||
* @param bits Number of output bits. Valid values: 224, 256, 384, 512
|
||||
*/
|
||||
export declare function createKeccak(bits?: IValidBits): Promise<IHasher>;
|
||||
export {};
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import { type IWASMInterface } from "./WASMInterface";
|
||||
import type Mutex from "./mutex";
|
||||
import type { IEmbeddedWasm } from "./util";
|
||||
export default function lockedCreate(mutex: Mutex, binary: IEmbeddedWasm, hashLength: number): Promise<IWASMInterface>;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates MD4 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function md4(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new MD4 hash instance
|
||||
*/
|
||||
export declare function createMD4(): Promise<IHasher>;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates MD5 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function md5(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new MD5 hash instance
|
||||
*/
|
||||
export declare function createMD5(): Promise<IHasher>;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
declare class Mutex {
|
||||
private mutex;
|
||||
lock(): PromiseLike<() => void>;
|
||||
dispatch<T>(fn: () => PromiseLike<T>): Promise<T>;
|
||||
}
|
||||
export default Mutex;
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import type { IHasher } from "./WASMInterface";
|
||||
import { type IDataType } from "./util";
|
||||
export interface IPBKDF2Options {
|
||||
/**
|
||||
* Password (or message) to be hashed
|
||||
*/
|
||||
password: IDataType;
|
||||
/**
|
||||
* Salt (usually containing random bytes)
|
||||
*/
|
||||
salt: IDataType;
|
||||
/**
|
||||
* Number of iterations to perform
|
||||
*/
|
||||
iterations: number;
|
||||
/**
|
||||
* Output size in bytes
|
||||
*/
|
||||
hashLength: number;
|
||||
/**
|
||||
* Hash algorithm to use. It has to be the return value of a function like createSHA1()
|
||||
*/
|
||||
hashFunction: Promise<IHasher>;
|
||||
/**
|
||||
* Desired output type. Defaults to 'hex'
|
||||
*/
|
||||
outputType?: "hex" | "binary";
|
||||
}
|
||||
interface IPBKDF2OptionsBinary {
|
||||
outputType: "binary";
|
||||
}
|
||||
type PBKDF2ReturnType<T> = T extends IPBKDF2OptionsBinary ? Uint8Array : string;
|
||||
/**
|
||||
* Generates a new PBKDF2 hash for the supplied password
|
||||
*/
|
||||
export declare function pbkdf2<T extends IPBKDF2Options>(options: T): Promise<PBKDF2ReturnType<T>>;
|
||||
export {};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates RIPEMD-160 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function ripemd160(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new RIPEMD-160 hash instance
|
||||
*/
|
||||
export declare function createRIPEMD160(): Promise<IHasher>;
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import { type IDataType } from "./util";
|
||||
export interface ScryptOptions {
|
||||
/**
|
||||
* Password (or message) to be hashed
|
||||
*/
|
||||
password: IDataType;
|
||||
/**
|
||||
* Salt (usually containing random bytes)
|
||||
*/
|
||||
salt: IDataType;
|
||||
/**
|
||||
* CPU / memory cost - must be a power of 2 (e.g. 1024)
|
||||
*/
|
||||
costFactor: number;
|
||||
/**
|
||||
* Block size (8 is commonly used)
|
||||
*/
|
||||
blockSize: number;
|
||||
/**
|
||||
* Degree of parallelism
|
||||
*/
|
||||
parallelism: number;
|
||||
/**
|
||||
* Output size in bytes
|
||||
*/
|
||||
hashLength: number;
|
||||
/**
|
||||
* Output data type. Defaults to hexadecimal string
|
||||
*/
|
||||
outputType?: "hex" | "binary";
|
||||
}
|
||||
interface IScryptOptionsBinary {
|
||||
outputType: "binary";
|
||||
}
|
||||
type ScryptReturnType<T> = T extends IScryptOptionsBinary ? Uint8Array : string;
|
||||
/**
|
||||
* Calculates hash using the scrypt password-based key derivation function
|
||||
* @returns Computed hash as a hexadecimal string or as
|
||||
* Uint8Array depending on the outputType option
|
||||
*/
|
||||
export declare function scrypt<T extends ScryptOptions>(options: T): Promise<ScryptReturnType<T>>;
|
||||
export {};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates SHA-1 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function sha1(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new SHA-1 hash instance
|
||||
*/
|
||||
export declare function createSHA1(): Promise<IHasher>;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates SHA-2 (SHA-224) hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function sha224(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new SHA-2 (SHA-224) hash instance
|
||||
*/
|
||||
export declare function createSHA224(): Promise<IHasher>;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates SHA-2 (SHA-256) hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function sha256(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new SHA-2 (SHA-256) hash instance
|
||||
*/
|
||||
export declare function createSHA256(): Promise<IHasher>;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
type IValidBits = 224 | 256 | 384 | 512;
|
||||
/**
|
||||
* Calculates SHA-3 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param bits Number of output bits. Valid values: 224, 256, 384, 512
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function sha3(data: IDataType, bits?: IValidBits): Promise<string>;
|
||||
/**
|
||||
* Creates a new SHA-3 hash instance
|
||||
* @param bits Number of output bits. Valid values: 224, 256, 384, 512
|
||||
*/
|
||||
export declare function createSHA3(bits?: IValidBits): Promise<IHasher>;
|
||||
export {};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates SHA-2 (SHA-384) hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function sha384(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new SHA-2 (SHA-384) hash instance
|
||||
*/
|
||||
export declare function createSHA384(): Promise<IHasher>;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates SHA-2 (SHA-512) hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function sha512(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new SHA-2 (SHA-512) hash instance
|
||||
*/
|
||||
export declare function createSHA512(): Promise<IHasher>;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates SM3 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function sm3(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new SM3 hash instance
|
||||
*/
|
||||
export declare function createSM3(): Promise<IHasher>;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
export type ITypedArray = Uint8Array | Uint16Array | Uint32Array;
|
||||
export type IDataType = string | Buffer | ITypedArray;
|
||||
export type IEmbeddedWasm = {
|
||||
name: string;
|
||||
data: string;
|
||||
hash: string;
|
||||
};
|
||||
export declare function intArrayToString(arr: Uint8Array, len: number): string;
|
||||
export declare function writeHexToUInt8(buf: Uint8Array, str: string): void;
|
||||
export declare function hexStringEqualsUInt8(str: string, buf: Uint8Array): boolean;
|
||||
export declare function getDigestHex(tmpBuffer: Uint8Array, input: Uint8Array, hashLength: number): string;
|
||||
export declare const getUInt8Buffer: (data: IDataType) => Uint8Array;
|
||||
export declare function encodeBase64(data: Uint8Array, pad?: boolean): string;
|
||||
export declare function getDecodeBase64Length(data: string): number;
|
||||
export declare function decodeBase64(data: string): Uint8Array;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates Whirlpool hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function whirlpool(data: IDataType): Promise<string>;
|
||||
/**
|
||||
* Creates a new Whirlpool hash instance
|
||||
*/
|
||||
export declare function createWhirlpool(): Promise<IHasher>;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates xxHash128 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param seedLow Lower 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
* @param seedHigh Higher 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function xxhash128(data: IDataType, seedLow?: number, seedHigh?: number): Promise<string>;
|
||||
/**
|
||||
* Creates a new xxHash128 hash instance
|
||||
* @param seedLow Lower 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
* @param seedHigh Higher 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
*/
|
||||
export declare function createXXHash128(seedLow?: number, seedHigh?: number): Promise<IHasher>;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates xxHash3 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param seedLow Lower 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
* @param seedHigh Higher 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function xxhash3(data: IDataType, seedLow?: number, seedHigh?: number): Promise<string>;
|
||||
/**
|
||||
* Creates a new xxHash3 hash instance
|
||||
* @param seedLow Lower 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
* @param seedHigh Higher 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
*/
|
||||
export declare function createXXHash3(seedLow?: number, seedHigh?: number): Promise<IHasher>;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates xxHash32 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param seed Number used to initialize the internal state of the algorithm (defaults to 0)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function xxhash32(data: IDataType, seed?: number): Promise<string>;
|
||||
/**
|
||||
* Creates a new xxHash32 hash instance
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param seed Number used to initialize the internal state of the algorithm (defaults to 0)
|
||||
*/
|
||||
export declare function createXXHash32(seed?: number): Promise<IHasher>;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { type IHasher } from "./WASMInterface";
|
||||
import type { IDataType } from "./util";
|
||||
/**
|
||||
* Calculates xxHash64 hash
|
||||
* @param data Input data (string, Buffer or TypedArray)
|
||||
* @param seedLow Lower 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
* @param seedHigh Higher 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
* @returns Computed hash as a hexadecimal string
|
||||
*/
|
||||
export declare function xxhash64(data: IDataType, seedLow?: number, seedHigh?: number): Promise<string>;
|
||||
/**
|
||||
* Creates a new xxHash64 hash instance
|
||||
* @param seedLow Lower 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
* @param seedHigh Higher 32 bits of the number used to
|
||||
* initialize the internal state of the algorithm (defaults to 0)
|
||||
*/
|
||||
export declare function createXXHash64(seedLow?: number, seedHigh?: number): Promise<IHasher>;
|
||||
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* hash-wasm (https://www.npmjs.com/package/hash-wasm)
|
||||
* (c) Dani Biro
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).hashwasm=e.hashwasm||{})}(this,(function(e){"use strict";function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function u(e){try{f(r.next(e))}catch(e){o(e)}}function a(e){try{f(r.throw(e))}catch(e){o(e)}}function f(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}f((r=r.apply(e,t||[])).next())}))}var n;"function"==typeof SuppressedError&&SuppressedError;const r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,i=null!==(n=r.Buffer)&&void 0!==n?n:null,o=r.TextEncoder?new r.TextEncoder:null,u="a".charCodeAt(0)-10,a="0".charCodeAt(0);const f=null!==i?e=>{if("string"==typeof e){const t=i.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(i.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return o.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=new Uint8Array(256);for(let e=0;e<s.length;e++)d[s.charCodeAt(e)]=e;function l(e,t){e.init();const{blockSize:n}=e,r=function(e,t){const{blockSize:n}=e,r=f(t);if(r.length>n){e.update(r);const t=e.digest("binary");return e.init(),t}return new Uint8Array(r.buffer,r.byteOffset,r.length)}(e,t),i=new Uint8Array(n);i.set(r);const o=new Uint8Array(n);for(let e=0;e<n;e++){const t=i[e];o[e]=92^t,i[e]=54^t}e.update(i);const u={init:()=>(e.init(),e.update(i),u),update:t=>(e.update(t),u),digest:t=>{const n=e.digest("binary");return e.init(),e.update(o),e.update(n),e.digest(t)},save:()=>{throw new Error("save() not supported")},load:()=>{throw new Error("load() not supported")},blockSize:e.blockSize,digestSize:e.digestSize};return u}function h(e,n,r,i,o){return t(this,void 0,void 0,(function*(){const t=new Uint8Array(i),s=new Uint8Array(n.length+4),d=new DataView(s.buffer),l=f(n),h=new Uint8Array(l.buffer,l.byteOffset,l.length);s.set(h);let p=0;const c=e.digestSize,y=Math.ceil(i/c);let w=null,b=null;for(let o=1;o<=y;o++){d.setUint32(n.length,o),e.init(),e.update(s),w=e.digest("binary"),b=w.slice();for(let t=1;t<r;t++){e.init(),e.update(b),b=e.digest("binary");for(let e=0;e<c;e++)w[e]^=b[e]}t.set(w.subarray(0,i-p),p),p+=c}if("binary"===o)return t;return function(e,t,n){let r=0;for(let i=0;i<n;i++){let n=t[i]>>>4;e[r++]=n>9?n+u:n+a,n=15&t[i],e[r++]=n>9?n+u:n+a}return String.fromCharCode.apply(null,e)}(new Uint8Array(2*i),t,i)}))}e.pbkdf2=function(e){return t(this,void 0,void 0,(function*(){(e=>{if(!e||"object"!=typeof e)throw new Error("Invalid options parameter. It requires an object.");if(!e.hashFunction||!e.hashFunction.then)throw new Error('Invalid hash function is provided! Usage: pbkdf2("password", "salt", 1000, 32, createSHA1()).');if(!Number.isInteger(e.iterations)||e.iterations<1)throw new Error("Iterations should be a positive number");if(!Number.isInteger(e.hashLength)||e.hashLength<1)throw new Error("Hash length should be a positive number");if(void 0===e.outputType&&(e.outputType="hex"),!["hex","binary"].includes(e.outputType))throw new Error(`Insupported output type ${e.outputType}. Valid values: ['hex', 'binary']`)})(e);return h(yield function(e,t){if(!e||!e.then)throw new Error('Invalid hash function is provided! Usage: createHMAC(createMD5(), "key").');return e.then((e=>l(e,t)))}(e.hashFunction,e.password),e.salt,e.iterations,e.hashLength,e.outputType)}))}}));
|
||||
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user