open-index/open-npm huggingface dataset:
npm package: @safez/safez-cryptx
Description: Introducing safez-cryptx, the npm package that sets a new standard in data encryption for developers working across both Node.js and browser environments.safez-cryptx focuses on providing developers with advanced AES-CBC symmetric encryption capabilities 
Author: arunkumarr@clarium.tech, arunkumars@clarium.tech, judejosephmsm@clarium.tech, ramyas@clarium.tech, sririshikeshb@clarium.tech, vigneshwaranp@clarium.tech
Latest version: 1.0.0

# Overview of safez-CryptX
safez-CryptX is a versatile encryption and decryption library designed for both Node.js and browser environments. It supports various encryption modes, allowing developers to encrypt entire objects, specific fields within objects, or simple values. This document provides a comprehensive guide on how to integrate and use safez-CryptX in your projects.
## Installation
Add safez-cryptx to your project using the following command:
```bash
npm install @safez/safez-cryptx
# or
yarn add @safez/safez-cryptx
```
## Setup and Configuration
To use safez-CryptX, import it into your project and configure it with your encryption settings. This setup will automatically encrypt and decrypt data based on the specified configurations.
### Import in commonjs frameworks
```javascript
const { encryptValue, decryptValue } = require('@safez/safez-cryptx');
```
### Import in module frameworks
```typescript
import * as cryptx from '@safez/safez-cryptx';
```
## Usage
### Basic Encryption and Decryption
Encrypt and decrypt values simply and effectively with safez-CryptX.

```javascript
let encrypted = encryptValue('Hello World!', 'dummysecretkey');
console.log(encrypted); // Encrypted data
let decrypted = decryptValue(encrypted, 'dummysecretkey');
console.log(decrypted); // Hello World!
```
### Object Encryption and Decryption
Manage encryption and decryption of entire objects or specific fields within objects.
#### Cryptx in Entire Object
```javascript
const data = {
 name: 'SafeZ',
 type: 'security'
};
const encrypted = cryptx.encryptData(data, 'dummykey', 'full');
const decrypted = cryptx.decryptData(encrypted, 'dummykey', 'full');
console.log(encrypted); // Encrypted string
console.log(decrypted); // {name: "SafeZ", type: "security"}
```
#### Cryptx in Object Values
```javascript
const data = {
 name: 'SafeZ',
 type: 'security'
};
const encrypted = cryptx.encryptData(data, 'dummykey', 'field');
const decrypted = cryptx.decryptData(encrypted, 'dummykey', 'field');
console.log(encrypted); // {name: "encrypted string", type: "encrypted string"}
console.log(decrypted); // {name: "SafeZ", type: "security"}
```

### Best Practices
- **Encryption Secret Management**: Keep your encryption secret key secure and avoid exposing it in client-side code.
- **Optimize Encryption Use**: Use encryption selectively, balancing security needs with performance.
### Troubleshooting
- **Usage Failures**: Check that the package is installed, secret key is correctly configured.

## Frequently Asked Questions (FAQ)
- **Can safez-CryptX be used in any web application?**
  Yes, it's designed to be compatible across both Node.js and browser environments.