New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

system-secured-storage

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

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

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 nametyperequiredDescription
directorystringtrueThe directory to save/retrive the data from/to.
encryptionKeystringtrueThe AES encryption key. The key can be 128, 192, or 256 bits long
ivKeystringtrueThe 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 date by key
const decryptedData = storage.deleteData('mykey');

Reset storage

To reset storage meaning deleting all data:

// Delete date by key
const decryptedData = storage.reset();

Keywords

encrypted storage

FAQs

Package last updated on 26 Jan 2025

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