https://github.com/matyilasango/system-secured-storage
A Node.js project that allows users to store encrypted key-value data locally on their system. This project serves as an alternate storage solution to SQLite but with enhanced security features, leveraging AES encryption to ensure the confidentiality and integrity of the stored data.
https://github.com/matyilasango/system-secured-storage
secure-storage security system-security
Last synced: 4 months ago
JSON representation
A Node.js project that allows users to store encrypted key-value data locally on their system. This project serves as an alternate storage solution to SQLite but with enhanced security features, leveraging AES encryption to ensure the confidentiality and integrity of the stored data.
- Host: GitHub
- URL: https://github.com/matyilasango/system-secured-storage
- Owner: MatyilaSango
- License: mit
- Created: 2025-01-25T08:11:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-26T17:28:04.000Z (over 1 year ago)
- Last Synced: 2025-09-05T07:38:05.973Z (9 months ago)
- Topics: secure-storage, security, system-security
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/system-secured-storage
- Size: 62.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Encrypted Key-Value Storage with Node.js
A Node.js package that allows users to store encrypted key-value data locally on their system. This project serves as an alternate storage solution to SQLite but with enhanced security features, leveraging AES encryption to ensure the confidentiality and integrity of the stored data.
## Features
- Store key-value data locally on the system in an encrypted format.
- Use of AES encryption to secure the data.
- A simple and secure alternative to SQLite for local storage needs.
- Easy-to-use API for data storage and retrieval.
## How It Works
The project uses AES encryption to secure the data before storing it locally on the user's system. The key-value pairs are stored in a file, and the data is encrypted using a secret key. The secret key is not stored in the project, ensuring that only authorized users with the correct key can decrypt the data.
## AES Encryption
AES (Advanced Encryption Standard) is used to securely encrypt and decrypt the data before saving and retrieving it from the local storage. This ensures that the stored data cannot be easily read or tampered with.
## Usage
#### Options
| Property name | type | required | Description |
| ------------- | ------ | -------- | ----------------------------------------------------------------- |
| directory | string | true | The directory to save/retrive the data from/to. |
| encryptionKey | string | true | The AES encryption key. The key can be 128, 192, or 256 bits long |
| ivKey | string | true | The AES iv key. |
### Generating encryption and iv keys
You can generate these keys using online services or with the use of node package `crypto`.
They can be generated using cli.
```
// Using node
> node
// Genarate random string for the `encryption` key - 16 Characters
> require('crypto').randomBytes(32).toString('hex')
// Genarate random string for the `iv` key - 16 Characters
> require('crypto').randomBytes(16).toString('hex')
```
Make sure to store your keys somewhere safely.
### Using system-secure-storage
Create an instance of the system-secure-storage with your desired `options`.
```
import SystemSecuredStorage from 'system-secured-storage';
const storage = new SystemSecuredStorage(options)
```
#### Storing Data
To store a key-value pair securely, use the `storeData` method:
```
// Encrypt and store the key-value pair
storage.storeData('myKey', 'mySensitiveData');
```
#### Retrieving Data
To retrieve the decrypted data:
```
// Retrieve and decrypt the data using the key
const decryptedData = storage.retrieveData('myKey');
```
#### Retrieving all data
To retrieve all the decrypted data:
```
// Retrieve and decrypt the data using the key
const decryptedData = storage.retrieveAll();
```
#### Delete data
To delete data:
```
// Delete data by key
const decryptedData = storage.deleteData('mykey');
```
#### Reset storage
To reset storage meaning deleting all the data:
```
// Reset storage
storage.reset();
```