prorm API Reference
    Preparing search index...

    Class ALGORITHM

    ALGORITHM - data type for hash algorithms Used for storing hashed values (passwords, checksums, etc.) Can be used with VIRTUAL type for computed/hashed fields

    Common output lengths:

    • MD5: 32 hex chars (16 bytes)
    • SHA1: 40 hex chars (20 bytes)
    • SHA256: 64 hex chars (32 bytes)
    • SHA384: 96 hex chars (48 bytes)
    • SHA512: 128 hex chars (64 bytes)
    • BCRYPT: 60 chars (with $2a$ or $2b$ prefix)
    • ARGON2: Variable, typically ~100 chars (with $argon2$ prefix)
    • PBKDF2: Variable based on hash length
    // Store password hash using BCRYPT (recommended for passwords)
    password: DataTypes.ALGORITHM({ algorithm: 'BCRYPT', cost: 12 })

    // Store checksum using SHA256
    fileChecksum: DataTypes.ALGORITHM({ algorithm: 'SHA256' })

    // Store password hash using ARGON2
    password: DataTypes.ALGORITHM({ algorithm: 'ARGON2', cost: 65536, parallelism: 2 })

    // Use with VIRTUAL for auto-hashing on set
    passwordHash: DataTypes.VIRTUAL({
    returnType: DataTypes.ALGORITHM({ algorithm: 'BCRYPT' }),
    set(value: string) {
    this.password = hashPassword(value);
    }
    })

    Hierarchy (View Summary)

    Index
    key: "ALGORITHM" = ...
    algorithm: HashAlgorithm

    The hash algorithm to use

    cost?: number

    Cost factor/rounds for the algorithm

    saltLength?: number

    Salt length in bytes

    hashLength?: number

    Hash length in bytes

    includeSalt?: boolean

    Whether to include salt in output

    parallelism?: number

    Parallelism parameter (for ARGON2)

    blockSize?: number

    Block size parameter (for ARGON2)

    • Serialize a value for storage based on this DataType

      Parameters

      • value: unknown

        The value to serialize

      Returns unknown

      The serialized value

    • Check if this is a password hashing algorithm (slow hash) Password hashing algorithms are designed to be slow to prevent brute force

      Returns boolean

    • Check if this is a fast hash algorithm (checksums)

      Returns boolean

    • Get the configuration object for hashing libraries

      Returns object