/** * Bcrypt and Node cypher. */ export declare class Crypto { /** * App secret key. */ readonly secret: string; /** * Bcrypt salt round. */ readonly saltRound: number | string; /** * Decipher algorithm. */ readonly algorithm: string; /** * Compare a string with a hash. * * ```ts * class AuthCtrl { * @inject userRepository: UserRepository; * @inject crypto: Crypto; * * @post("/") * async login(@body data: LoginBody) { * * const user = this.userRepository.findByEmail(data.email); * if (!user) throw new UnauthorizedException(); * * const match = await crypto.compare(data.password, user.password); * if (!match) throw new UnauthorizedException(); * * // ... * } * } * * ``` * * @param entry Raw string * @param hash Hash */ compare(entry: string, hash: string): Promise; /** * Generate salt used by bcrypt. * * @return Salt as string when process is done. */ salt(): Promise; /** * Hash a string with bcrypt. * * ```ts * const crypto = k.get(Crypto); * const hash = await crypto.hash("password"); * ``` * * @param data * @param salt * @return {Promise} */ hash(data: string, salt?: string): Promise; /** * Encrypt string data to hex with algo and secret. * * @param text Data to encrypt * @param base64 If true, output will be base64 * @return {string} */ encrypt(text: string, base64?: boolean): string; /** * Decrypt a string with algo and secret. * * @param text Data to decrypt * @param base64 if true, input will be parse as base64 * @return {string} */ decrypt(text: string, base64?: boolean): string; }