Socket
Book a DemoInstallSign in
Socket

@evokegroup/crypto

Package Overview
Dependencies
Maintainers
4
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evokegroup/crypto

Crypto utilities

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
4
Weekly downloads
 
Created
Source

@evokegroup/crypto

Requires NodeJS 18+

Encryption

Classes

UnsupportedAlgorithmError

extends Error

InvalidInputLengthError

extends Error

Interfaces

EncryptOpts

PropertyType
inputEncodingBufferEncoding
keyEncodingBufferEncoding
ivEncodingBufferEncoding
outputEncodingBufferEncoding
iterationsnumber
hmacstring
authTagLengthnumber
authTagLocationAuthTagLocation

DecryptOpts

extends EncryptOpts

PropertyType
authTagBuffer|string

EncryptionResult

PropertyTypeDefaultDescription
dataBuffer, stringThe encrypted data
authTagBuffer, stringThe authentication tag

Methods

decrypt

returns Promise<Buffer | string>

ParameterTypeDefaultDescription
algorithmstringThe encryption algorithm
dataBuffer, stringThe data to be encrypted
keyBuffer, stringThe encryption key
ivBuffer, stringThe encryption IV
optsDecryptOpts
opts.inputEncodingBufferEncodingutf8
opts.keyEncodingBufferEncodingbase64
opts.ivEncodingBufferEncodingbase64
opts.outputEncodingBufferEncodingbase64null will cause the returned value to be a Buffer.
opts.iterationsnumber1000
opts.hmacstringsha256
opts.authTagBuffer, string
opts.authTagLengthnumber16
opts.authTagLocationnumberAPPEND

decryptSync

returns Buffer | string

ParameterTypeDefaultDescription
algorithmstringThe encryption algorithm
dataBuffer, stringThe data to be encrypted
keyBuffer, stringThe encryption key
ivBuffer, stringThe encryption IV
optsDecryptOpts
opts.inputEncodingBufferEncodingutf8
opts.keyEncodingBufferEncodingbase64
opts.ivEncodingBufferEncodingbase64
opts.outputEncodingBufferEncodingbase64null will cause the returned value to be a Buffer.
opts.iterationsnumber1000
opts.hmacstringsha256
opts.authTagBuffer, string
opts.authTagLengthnumber16
opts.authTagLocationnumberAPPEND

encrypt

returns Promise<Buffer | string | EncryptionResult>

ParameterTypeDefaultDescription
algorithmstringThe encryption algorithm
dataBuffer, stringThe data to be encrypted
keyBuffer, stringThe encryption key
ivBuffer, stringThe encryption IV
optsEncryptOpts
opts.inputEncodingBufferEncodingutf8
opts.keyEncodingBufferEncodingbase64
opts.ivEncodingBufferEncodingbase64
opts.outputEncodingBufferEncodingbase64null will cause the returned value to be a Buffer.
opts.iterationsnumber1000
opts.hmacstringsha256
opts.authTagLengthnumber16
opts.authTagLocationnumberAPPEND

encryptSync

returns Buffer | string | EncryptionResult

ParameterTypeDefaultDescription
algorithmstringThe encryption algorithm
dataBuffer, stringThe data to be encrypted
keyBuffer, stringThe encryption key
ivBuffer, stringThe encryption IV
optsEncryptOpts
opts.inputEncodingBufferEncodingutf8
opts.keyEncodingBufferEncodingbase64
opts.ivEncodingBufferEncodingbase64
opts.outputEncodingBufferEncodingbase64null will cause the returned value to be a Buffer.
opts.iterationsnumber1000
opts.hmacstringsha256
opts.authTagLengthnumber16
opts.authTagLocationnumberAPPEND

generateRandomKey

returns Buffer | string

Generates a random key appropriate for the given encryption algorithm.

ParameterTypeDefaultDescription
algorithmstringThe encryption algorithm
outputEncodingBufferEncoding

generateRandomIV

returns Buffer | string

Generates a random initialization vector appropriate for the given encryption algorithm.

ParameterTypeDefaultDescription
algorithmstringThe encryption algorithm
outputEncodingBufferEncoding

getSupportedAlgorithms

returns string[]

Get a list of algorithms supported by this library.

ParameterTypeDefaultDescription
schemestringnullReturn algorithms only for the given encryption scheme (e.g. aes, aria, camellia, des, des3)

isSupportedAlgorithm

returns boolean

ParameterTypeDefaultDescription
algorithmstring

Hashing

Interfaces

HashOpts

PropertyType
saltBuffer, string
saltEncodingBufferEncoding
saltLocationSaltLocation
inputEncodingBufferEncoding
outputEncodingBinaryToTextEncoding

Methods

calculateHash

returns Buffer | string

ParameterTypeDefaultDescription
algorithmstringThe encryption algorithm
dataBuffer, stringThe data to be encrypted
optsHashOpts
opts.saltBuffer, string
opts.saltEncodingBufferEncodingbase64
opts.saltLocationSaltLocationAPPEND
opts.inputEncodingBufferEncodingutf8
opts.outputEncodingBinaryToTextEncodinghexnull will cause the returned value to be a Buffer.

generateSalt

returns Buffer | string

ParameterTypeDefaultDescription
saltLengthnmber16
outputEncodingBufferEncoding

FAQs

Package last updated on 19 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.