Class CryptoUtils

Hierarchy

  • CryptoUtils

Index

Methods

Static decrypt

  • decrypt(message: string, password: string): string | null
  • Decrypt AES256-CBC encrypted message in form of string representation of following type { ct: string, iv: string, s: string }

    Parameters

    • message: string

      Serialized encrypted message to be decrypted.

    • password: string

      Password for decryption.

    Returns string | null

    Decrypted message.

Static decryptHexString

  • decryptHexString(message: string, password: string): string
  • Decrypts AES256-CBC encrypted hex string message. Result is decrypted string. This decryption is compatible with wallet-cli wallet file export key encryption format.

    Parameters

    • message: string

      Message to be decrypted.

    • password: string

      Password for decryption.

    Returns string

    Decrypted message.

Static decryptWithChecksum

  • decryptWithChecksum(message: string, privateKey: string, publicKey: string, nonce?: string): string
  • Decrypts message encrypted by CryptoUtils.encryptWithChecksum or memo from DCore network objects.

    Parameters

    • message: string

      Encrypted message.

    • privateKey: string

      Private key of one of communicating sides. Used to decrypt message.

    • publicKey: string

      Public key of other communicating side. Used to decrypt message.

    • Default value nonce: string = ""

      Random number used in decryption. Default ''.

    Returns string

    Buffer with decrypted text.

Static encrypt

  • encrypt(message: string, password: string): string
  • Encrypt message using AES256-CBC. Encrypted text is in string representation of following type { ct: string, iv: string, s: string }

    Parameters

    • message: string

      Message to be encrypted.

    • password: string

      Password for encryption.

    Returns string

    Encrypted serialized message.

Static encryptToHexString

  • encryptToHexString(message: string | Buffer, password: string): string
  • Encrypt message with AES256-CBC. Result is encrypted hex string. This encryption is compatible with wallet-cli wallet file export key encryption format.

    Parameters

    • message: string | Buffer

      Message to be encrypted.

    • password: string

      Password for encryption.

    Returns string

    Encrypted message.

Static encryptWithChecksum

  • encryptWithChecksum(message: string, privateKey: string, publicKey: string, nonce?: string): string
  • Encrypts message with given private-pubic key pair

    Parameters

    • message: string

      Message to encrypt.

    • privateKey: string

      Private of one side of communication, to encrypt message with.

    • publicKey: string

      Public key of other side of communication, used in encryption.

    • Default value nonce: string = ""

    Returns string

    String in HEX format with encrypted message.

Static md5

  • md5(message: string): string
  • Calculates MD5 hash out of input.

    Parameters

    • message: string

      Input message.

    Returns string

    Hashed input.

Static ripemdHash

  • ripemdHash(fromBuffer: string): string
  • Calculate RIPEMD160 hash from input. Used as 'hash' parameter when submitting content.

    Parameters

    • fromBuffer: string

      Input to calculate buffer from.

    Returns string

    RIPEMD160 hashed text.

Static sha256

  • sha256(message: string): string
  • Calculates SHA256 hash of input.

    Parameters

    • message: string

      Input message.

    Returns string

    Hashed input.

Static sha512

  • sha512(message: string): string
  • Calculates SHA512 hash of input.

    Parameters

    • message: string

      Input message.

    Returns string

    Hashed input.

Powered by DECENT