Page MenuHomeSealhub

password.ts
No OneTemporary

password.ts

import SecureHasher from "../../../utils/secure-hasher";
import { Context, Field } from "../../../main";
const MIN_LENGTH = 8;
export default class Password extends Field {
typeName = "password";
async isProperValue(context: Context, input: string) {
return input.length >= MIN_LENGTH
? Field.valid()
: Field.invalid(context.app.i18n("invalid_password", [MIN_LENGTH]));
}
async encode(_: Context, input: string) {
if (input === null) {
return null;
}
const hash_params = this.app.ConfigManager.get("password_hash");
const salt = SecureHasher.generateRandomSalt(hash_params.salt_length);
return SecureHasher.hash(input, salt, hash_params);
}
async decode() {
return "secret";
}
}

File Metadata

Mime Type
text/x-Algol68
Expires
Sun, Jul 13, 04:49 (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
783118
Default Alt Text
password.ts (713 B)

Event Timeline