Crypto Js

JavaScript library of crypto standards.

Overview

This node provides cryptographic operations using JavaScript libraries, enabling encryption, decryption, signing, and Base64 decoding of strings or JSON data. It supports both symmetric encryption with a passphrase and asymmetric encryption/decryption/signing with private/public keys.

Common scenarios include:

  • Encrypting sensitive data before storage or transmission.
  • Decrypting received encrypted data.
  • Signing data to verify authenticity.
  • Decoding Base64 encoded strings.

Practical examples:

  • Encrypt a JSON object containing user credentials with a passphrase before saving it.
  • Decrypt an encrypted message received from another system using a private key.
  • Sign a payload with a private key to ensure its integrity.
  • Decode Base64 encoded data received from an API.

Properties

Name Meaning
Action The cryptographic operation to perform. Options: Encrypt (passphrase), Encrypt Private Key, Decrypt (private key), Decrypt Public Key, Sign (private key), Base64 Decode.
Input Type Specifies the input format for certain actions (Encrypt, Encrypt Private, Sign). Options: String, Json.
Input Value The string or JSON value to be processed by the selected action.
Encrypt Output Type Format of the encrypted output. Currently only Base64 is supported.
Decrypt Output Type Format of the decrypted output. Options: String, Json.
Output Property Name The name of the property in the output JSON where the result will be stored.

Output

The node outputs an array of items, each containing a json object with the result of the cryptographic operation stored under the specified output property name.

  • For encryption, decryption, and signing, the output property contains the resulting string or parsed JSON depending on the chosen output type.
  • For Base64 decode, the output property contains the decoded string.
  • If the input item contains binary data and no transformation disables it, the binary data is preserved in the output.
  • In case of errors (if "Continue On Fail" is enabled), the output includes an error message under the error property.

Dependencies

  • Requires an API key credential that provides either a passphrase or a private key, depending on the selected action.
  • Uses the crypto-js library for AES encryption/decryption.
  • Uses the node-rsa library for RSA encryption, decryption, and signing.
  • No additional environment variables are required beyond the configured credentials.

Troubleshooting

  • Missing Passphrase or Private Key: Actions requiring a passphrase or private key will throw an error if these credentials are not provided. Ensure the correct credential is configured.
  • Invalid Input Format: When selecting JSON as input or output type, invalid JSON strings may cause parsing errors. Validate JSON formatting before use.
  • Decryption Errors: Using incorrect keys or corrupted encrypted data will result in decryption failures. Verify keys and input data integrity.
  • Base64 Decode Issues: Input must be valid Base64 encoded strings; otherwise, decoding will fail or produce unexpected results.

Links and References

Discussion