Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Crypto

Hierarchy

  • Crypto

Index

Constructors

constructor

Properties

Static Private AES_ALGO

AES_ALGO: string = 'aes-256-gcm'

Methods

Static _decode

  • _decode(recipientPrivate: string, senderPublic: string, payload: Uint8Array, tagAndIv: Uint8Array): string
  • Decode an encrypted message payload

    Parameters

    • recipientPrivate: string

      A recipient private key

    • senderPublic: string

      A sender public key

    • payload: Uint8Array

      An encrypted message payload in bytes

    • tagAndIv: Uint8Array

      16-bytes AES auth tag and 12-byte AES initialization vector

    Returns string

    • The decoded payload as hex

Static _encode

  • _encode(senderPriv: string, recipientPub: string, msg: string, iv: Uint8Array): string
  • Encode a message, separated from encode() to help testing

    Parameters

    • senderPriv: string

      A sender private key

    • recipientPub: string

      A recipient public key

    • msg: string

      A text message

    • iv: Uint8Array

      An initialization vector

    Returns string

    • The encoded message

Static decode

  • decode(recipientPrivate: string, senderPublic: string, payload: string): string
  • Decode an encrypted (AES-GCM algorithm) message payload

    Parameters

    • recipientPrivate: string

      A recipient private key

    • senderPublic: string

      A sender public key

    • payload: string

      An encrypted message payload

    Returns string

    • The decoded payload as hex

Static decrypt

  • decrypt(data: string, password: string): string

Static encode

  • encode(senderPriv: string, recipientPub: string, msg: string, isHexString?: boolean): string
  • Encode a message using AES-GCM algorithm

    Parameters

    • senderPriv: string

      A sender private key

    • recipientPub: string

      A recipient public key

    • msg: string

      A text message

    • isHexString: boolean = false

      Is payload string a hexadecimal string (default = false)

    Returns string

    • The encoded message

Static encrypt

  • encrypt(data: string, password: string): string

Static randomBytes

  • randomBytes(length: number): any
  • Generate random bytes by length

    Parameters

    • length: number

      The length of the random bytes

    Returns any

Generated using TypeDoc