Hash
compare
The method compare() compares a raw value with a hashed value.
Type
ts
declare async function compare(value: string, hashedValue: string) : Promise<boolean>;Example
typescript
import {
compare,
hash
} from "@authup/server-kit";
(async () => {
const hashed = await hash('start123', 10); // 10 rounds
let isValid = await compare('start123', hashed);
console.log(isValid);
// true
});hash
The method hash() returns the hashed value of an input string.
Type
ts
declare async function hash(value: string, rounds?: number) : Promise<string>;Example
typescript
import {
hash
} from "@authup/server-kit";
(async () => {
const hashed = await hash('start123', 10); // 10 rounds
console.log(hashed);
// ...
});