-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a02cdd5
commit 716fce2
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Transform, TransformOptions } from 'bare-stream' | ||
import { Buffer, BufferEncoding } from 'bare-buffer' | ||
|
||
type Algorithm = 'MD5' | 'SHA1' | 'SHA256' | 'SHA512' | 'BLAKE2B256' | ||
|
||
export const constants: { hash: Record<Algorithm, number> } | ||
|
||
declare class CryptoError extends Error { | ||
static UNSUPPORTED_DIGEST_METHOD(msg: string): CryptoError | ||
} | ||
|
||
export class Hash extends Transform { | ||
constructor( | ||
algorithm: Algorithm | Lowercase<Algorithm> | number, | ||
opts?: TransformOptions | ||
) | ||
|
||
update(data: string | Buffer | DataView, encoding?: BufferEncoding): this | ||
|
||
digest(encoding?: BufferEncoding): string | Buffer | ||
} | ||
|
||
export function createHash( | ||
algorithm: Algorithm | Lowercase<Algorithm> | number, | ||
opts?: TransformOptions | ||
): Hash | ||
|
||
export function randomBytes( | ||
size: number, | ||
callback: (error: null, buffer: Buffer) => void | ||
): void | ||
|
||
export function randomBytes(size: number): Buffer | ||
|
||
export function randomFill<B extends ArrayBuffer | Buffer | DataView>( | ||
buffer: B, | ||
offset?: number, | ||
size?: number | ||
): B | ||
|
||
export function randomFill<B extends ArrayBuffer | Buffer | DataView>( | ||
buffer: B, | ||
offset: number, | ||
size: number, | ||
callback: (err: null, buffer: B) => void | ||
): void | ||
|
||
export function randomFill<B extends ArrayBuffer | Buffer | DataView>( | ||
buffer: B, | ||
offset: number, | ||
callback: (err: null, buffer: B) => void | ||
): void | ||
|
||
export function randomFill<B extends ArrayBuffer | Buffer | DataView>( | ||
buffer: B, | ||
callback: (err: null, buffer: B) => void | ||
): void | ||
|
||
export { CryptoError as errors, randomFill as randomFillSync } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters