JSPM

@utilify/crypto

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q8684F
  • License MIT

These functions are useful for ensuring data security and integrity in web and back-end applications.

Package Exports

  • @utilify/crypto
  • @utilify/crypto/dist/index.cjs
  • @utilify/crypto/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@utilify/crypto) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Utilities - Crypto

The Crypto category provides functions that help with generating cryptographic hashes and creating unique identifiers. These functions are useful for ensuring data security and integrity in web and back-end applications.

Installation

To install the Crypto package, use one of the following commands:

npm install @utilify/crypto
yarn add @utilify/crypto
pnpm add @utilify/crypto

Import the functions into your project:

import { djb2, hash, randomUUID } from '@utilify/crypto';
const { djb2, hash, randomUUID } = require('@utilify/crypto');

Overview

djb2

function djb2(str: string): string;

Calculates the DJB2 hash of a string. The DJB2 algorithm is a fast and efficient way to generate a hash from a text input.

hash

async function hash(
  data: string | ArrayBuffer | DataView,
  algorithm: 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512',
  output: 'hex' | 'base64' | 'buffer' = 'buffer'
): Promise<string | ArrayBuffer | undefined>;

Generates a cryptographic hash of the given data using the specified algorithm and output format.

randomUUID

function randomUUID(): string | undefined;

Generates a secure UUID using the browser's Web Crypto API. Returns undefined if the API is unavailable.