Options
All
  • Public
  • Public/Protected
  • All
Menu

@stacks/encryption

Encryption functions used by Stacks.js packages.

Installation

npm install @stacks/cli

Index

Type aliases

GetRandomBytes

GetRandomBytes: (count: number) => Buffer

Optional function to generate cryptographically secure random bytes

Type declaration

    • (count: number): Buffer
    • Parameters

      • count: number

      Returns Buffer

Functions

createSha2Hash

decryptContent

  • decryptContent(content: string, options?: { privateKey?: string }): Promise<string | Buffer>
  • Decrypts data encrypted with encryptContent with the transit private key.

    Parameters

    • content: string

      encrypted content.

    • Optional options: { privateKey?: string }
      • Optional privateKey?: string

        the hex string of the ECDSA private key to use for decryption. If not provided, will use user's appPrivateKey.

    Returns Promise<string | Buffer>

    decrypted content.

encryptContent

getBase64OutputLength

  • getBase64OutputLength(inputByteLength: number): number
  • Calculate the base64 encoded string length for a given input length. This is equivalent to the byte length when the string is ASCII or UTF8-8 encoded.

    Parameters

    • inputByteLength: number

    Returns number

hashSha256Sync

  • hashSha256Sync(data: Buffer): Buffer

hashSha512Sync

  • hashSha512Sync(data: Buffer): Buffer

Const randomBytes

  • randomBytes(size: number): Buffer
  • randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void
  • Parameters

    • size: number

    Returns Buffer

  • Parameters

    • size: number
    • callback: (err: Error | null, buf: Buffer) => void
        • (err: Error | null, buf: Buffer): void
        • Parameters

          • err: Error | null
          • buf: Buffer

          Returns void

    Returns void

Generated using TypeDoc