
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
This module provides a common implementation for standard cryptographic utilities, ciphers, IV management, low-level promitives and operations.
| Names | Description |
|---|---|
encrypt and decrypt | Symmetric AES-GCM encryption with a 32-byte prepended IV and support for data encoded as a Uint8Array or a string |
XOR | Bitwise Exclusive-OR between two Uint8Arrays of equal length |
keyFromString | Derives a CryptoKey from a string with PBKDF2 using a sane iteration count and the given salt |
encrypt(plaintext: Uint8Array|string, key: CryptoKey, returnType: string) => ciphertext: Uint8Array|stringEncrypts the given plaintext with the given key. Returns the ciphertext.
| Name | Description |
|---|---|
| plaintext | The data to encrypt. May be a String or a Uint8Array |
| key | The CryptoKey object to use for the encryption operation |
| returnType | A string indicating the desired return type. May be either string (default) or Uint8Array |
The function will either return a string or a Uint8Array representing the ciphertext, depending on the value of returnType.
decrypt(ciphertext: Uint8Array|string, key: CryptoKey, returnType: string) => plaintext: Uint8Array|stringDecrypts the given ciphertext with the given key. Returns the plaintext.
| Name | Description |
|---|---|
| ciphertext | The data to decrypt. May be a String or a Uint8Array |
| key | The CryptoKey object to use for the decryption operation |
| returnType | A string indicating the desired return type. May be either string (default) or Uint8Array |
The function will either return a string or a Uint8Array representing the plaintext, depending on the value of returnType.
keyFromString({ string: String, salt: Uint8Array }) => key: CryptoKeyDerives a suitable CryptoKey from the password string with PBKDF2 and the given salt.
| Name | Description |
|---|---|
| string | The password string to use |
| salt | a Uint8Array representing the password salt to use |
The function will return a CryptoKey object representing the derived key.
XOR(k1: Uint8Array, k2: Uint8Array) => result: Uint8ArrayPerforms a bitwise exclusive OR operation with the given data. Returns the result. Inputs must be the same length.
| Name | Description |
|---|---|
| k1 | A Uint8Array representing the first input to XOR |
| k2 | A Uint8Array representing the second input to XOR |
The function will return a Uint8Array containing the output data.
While this is not a React application, the react-scripts package is used for testing. I tried to get Jest to work on its own with the Web Cryptography API, TextEncoder and TextDecoder, but
was unable to find a suitable configuration. If anyone can get the tests to pass with only Jest, please feel free to create a pull request.
Adequate testing practices for use in a critical production application should be observed at all times for this library.
The license for the code in this repository is the Open BSV License.
FAQs
Common implementations for standard cryptographic utilities
The npm package cwi-crypto receives a total of 7 weekly downloads. As such, cwi-crypto popularity was classified as not popular.
We found that cwi-crypto demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.