security

Comprehensive security and cryptography utilities for encryption, hashing, identity generation, and browser fingerprinting.

Functions

UUID Generation

Function
Description
Example

uuid.v4

Generates a random UUID v4

dphelper.security.uuid.v4

uuid.v5

Generates a random UUID v5

dphelper.security.uuid.v5

uuid.byVal

Generates a deterministic UUID from a string

dphelper.security.uuid.byVal('string')

Encryption/Decryption

Function
Description
Example

crypt

Encrypts data using AES-256-GCM

await dphelper.security.crypt(data, secret)

deCrypt

Decrypts AES-256-GCM encrypted data

await dphelper.security.deCrypt(encrypted, secret)

AES_KeyGen

Generates a secure AES key

await dphelper.security.AES_KeyGen(passKey)

Hashing

Function
Description
Example

hashPass

Creates secure password hash with salt (SHA-256)

await dphelper.security.hashPass(user, pass)

SHA256_Hex

Generates SHA-256 hash in hexadecimal

await dphelper.security.SHA256_Hex(data)

Identity Generation

Function
Description
Example

ulid

Generates Universally Unique Lexicographically Sortable Identifier

dphelper.security.ulid()

fingerprint

Generates unique browser fingerprint

await dphelper.security.fingerprint()

Secure Storage

Function
Description
Example

saveEncrypted

Encrypts and saves data to localStorage with HMAC

await dphelper.security.saveEncrypted(key, value, secret)

getEncrypted

Retrieves and decrypts data from localStorage

await dphelper.security.getEncrypted(key, secret)

Description

Enterprise-grade security module providing:

  • UUID Generation - v4 (random), v5 (namespace-based), deterministic

  • Encryption - AES-256-GCM with PBKDF2 key derivation

  • Hashing - SHA-256 with secure salt generation

  • Identity - ULID for sortable unique IDs, browser fingerprinting

  • Secure Storage - Encrypted localStorage with HMAC integrity

Usage Examples

UUID Generation

Encryption/Decryption

Password Hashing

ULID Generation

Browser Fingerprinting

Secure LocalStorage

Security Features

AES-256-GCM Encryption

  • Uses PBKDF2 with 100,000 iterations for key derivation

  • Random 16-byte salt for each encryption

  • Random 12-byte IV (Initialization Vector)

  • Authenticated encryption (confidentiality + integrity)

Secure Password Hashing

  • SHA-256 algorithm

  • Random 16-byte salt per hash

  • Salt + hash stored together for verification

  • Time-safe comparison

HMAC-Protected Storage

  • AES encryption for confidentiality

  • HMAC-SHA256 for integrity verification

  • Tamper detection on retrieval

  • Version support for future updates

Advanced Usage

Complete Authentication Flow

Secure Message Passing

Details

  • Author: Dario Passariello & Jo

  • Version: 0.0.2

  • Creation Date: 20210101

  • Last Modified: 20260220

  • Environment: Works in both client and server environments


Automatically generated document

Last updated