Argon2 encryption library for Deno.
It uses rust-argon2 under the hood.
Library version | Deno Version |
---|---|
0.6.0 | 1.0.0-1.0.3 |
0.7.0 | 1.0.5 |
0.8.0 | 1.2.3 |
0.9.0 | 1.8.3 |
-
hash(password: string, options?: HashOptions): Promise<string>
-
verify(hash: string, password: string): Promise<boolean>
In case of error, all methods of this library will throw an
Argon2Error
type.
import { assert } from "https://deno.land/std/testing/asserts.ts";
import { hash, verify } from "https://deno.land/x/argon2/lib/mod.ts";
let hash = await hash("test");
assert(await verify(hash, "test"));
import { Variant } from "https://deno.land/x/argon2/lib/mod.ts";
import { assertArgon2Encoded } from "https://deno.land/x/argon2/lib/testing.ts";
Deno.test("User#password should be an argon2id variant password", async () => {
assertArgon2Encoded(user.password, {
variant: Variant.Argon2id,
});
});
The library can be installed as a CLI tool via deno install
.
Installation snippet
```sh
deno install \
-A \
--unstable \
argon2 https://deno.land/x/argon2/cli/argon2.ts
```
After install run --help
to inspect all possible commands.
The library automatically download the static library and initialize Deno plugin
via plugin_prepare and it
requires --allow-read
, --allow-write
, --allow-net
and --allow-plugin
.
```sh
deno \
--allow-read .deno_plugins \
--allow-write .deno_plugins \
--allow-net \
--allow-plugin \
--unstable \
lib/mod.ts
```
In the examples/
folder there you can find some usage examples.
To run examples you must
--allow-run
since dev environment builds and initialize the Rust crate.
Available examples
deno-argon2
├── lib/ # Core library
├── native/ # Native glue code
├── cli/ # CLI wrapper
├── tests/ # TypeScript tests
├── benches/ # TypeScript benchmarks
└── examples/ # Development examples