|
| 1 | +# `@node-rs/argon2` |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +[argon2](https://crates.io/crates/argon2) binding for Node.js. |
| 7 | + |
| 8 | +## Support matrix |
| 9 | + |
| 10 | +| | node12 | node14 | node16 | node17 | |
| 11 | +| ------------------- | ------ | ------ | ------ | ------ | |
| 12 | +| Windows x64 | ✓ | ✓ | ✓ | ✓ | |
| 13 | +| Windows x32 | ✓ | ✓ | ✓ | ✓ | |
| 14 | +| Windows arm64 | ✓ | ✓ | ✓ | ✓ | |
| 15 | +| macOS x64 | ✓ | ✓ | ✓ | ✓ | |
| 16 | +| macOS arm64(m chip) | ✓ | ✓ | ✓ | ✓ | |
| 17 | +| Linux x64 gnu | ✓ | ✓ | ✓ | ✓ | |
| 18 | +| Linux x64 musl | ✓ | ✓ | ✓ | ✓ | |
| 19 | +| Linux arm gnu | ✓ | ✓ | ✓ | ✓ | |
| 20 | +| Linux arm64 gnu | ✓ | ✓ | ✓ | ✓ | |
| 21 | +| Linux arm64 musl | ✓ | ✓ | ✓ | ✓ | |
| 22 | +| Android arm64 | ✓ | ✓ | ✓ | ✓ | |
| 23 | +| Android armv7 | ✓ | ✓ | ✓ | ✓ | |
| 24 | +| FreeBSD x64 | ✓ | ✓ | ✓ | ✓ | |
| 25 | + |
| 26 | +## API |
| 27 | + |
| 28 | +```typescript |
| 29 | +export const enum Algorithm { |
| 30 | + Argon2d = 0, |
| 31 | + Argon2i = 1, |
| 32 | + Argon2id = 2, |
| 33 | +} |
| 34 | +export const enum Version { |
| 35 | + V0x10 = 0, |
| 36 | + V0x13 = 1, |
| 37 | +} |
| 38 | +export interface Options { |
| 39 | + /** |
| 40 | + * Memory size, expressed in kilobytes, between 1 and (2^32)-1. |
| 41 | + * Value is an integer in decimal (1 to 10 digits). |
| 42 | + */ |
| 43 | + memoryCost?: number | undefined | null |
| 44 | + /** |
| 45 | + * Number of iterations, between 1 and (2^32)-1. |
| 46 | + * Value is an integer in decimal (1 to 10 digits). |
| 47 | + */ |
| 48 | + timeCost?: number | undefined | null |
| 49 | + /** |
| 50 | + * Degree of parallelism, between 1 and 255. |
| 51 | + * Value is an integer in decimal (1 to 3 digits). |
| 52 | + */ |
| 53 | + outputLen?: number | undefined | null |
| 54 | + parallelism?: number | undefined | null |
| 55 | + algorithm?: Algorithm | undefined | null |
| 56 | + version?: Version | undefined | null |
| 57 | + secret?: Buffer | undefined | null |
| 58 | +} |
| 59 | +export function hash( |
| 60 | + password: string | Buffer, |
| 61 | + options?: Options | undefined | null, |
| 62 | + abortSignal?: AbortSignal | undefined | null, |
| 63 | +): Promise<string> |
| 64 | +export function verify( |
| 65 | + hashed: string | Buffer, |
| 66 | + password: string | Buffer, |
| 67 | + options?: Options | undefined | null, |
| 68 | + abortSignal?: AbortSignal | undefined | null, |
| 69 | +): Promise<boolean> |
| 70 | +``` |
0 commit comments