npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

use-encrypt-storage

v0.0.32

Published

use-encrypt-storage is a simple and secure utility for managing browser localStorage with encryption. It provides a React hook that seamlessly integrates with the brower's localStorage and leverages the robust encryption capabilities of crypto-js. This pa

Downloads

24

Readme

Logo

use-encrypt-storage

use-encrypt-storage is a simple and secure react hook for managing browser localStorage with encryption. It provides a React hook that seamlessly integrates with the brower's localStorage and leverages the robust encryption capabilities of crypto-js. This package ensures that sensitive information stored in localStorage with encryption, adding an extra layer of protection to your application's data.

Roadmap

Documentation

Documentation

Installation

Install with npm

  npm install use-encrypt-storage

or :

Install with yarn

  yarn add use-encrypt-storage

Examples

Use with Vite ( in main.js )

import App from './App';
import { EncryptProvider } from "use-encrypt-storage";
...

function App() {
  return (
    <EncryptProvider secretKey={import.env.meta.VITE_SECRET_KEY}>
      <App />
    </EncryptProvider>
  );
}

Use with CRA ( in index.js )

import App from './App';
import { EncryptProvider } from "use-encrypt-storage";
...

function App() {
  return (
    <EncryptProvider secretKey={process.env.REACT_APP_SECRET_KEY}>
      <App />
    </EncryptProvider>
  );
}

Use with both

Set Data

import { useCallback } from "react";
import { useEncryptStorage } from "use-encrypt-storage";
...

function App() {
  const { set } = useEncryptStorage();

  // set( key: string , value: string , expireTime?: number | undefinded )
  // expireTime is in minutes

  const onSetHandler = useCallback(() => {
    set("name", "Ma Ma Thwe");
  }, []);


  return (
      <button onClick={onSetHandler}>
        Set Name
      </button>
  );
}

Get Data

import { useCallback } from "react";
import { useEncryptStorage } from "use-encrypt-storage";
...

function App() {
  const { get } = useEncryptStorage();

  // get( key: string )

  const onGetHandler = useCallback(() => {
    const name = get("name");

    console.log(name); // Ma Ma Thwe
  }, []);


  return (
      <button onClick={onGetHandler}>
        Get Name
      </button>
  );
}

Remove Data

import { useCallback } from "react";
import { useEncryptStorage } from "use-encrypt-storage";
...

function App() {
  const { remove } = useEncryptStorage();

  // remove( key: string )

  const onRemoveHandler = useCallback(() => {
    remove("name");
  }, []);


  return (
      <button onClick={onRemoveHandler}>
        Remove Name
      </button>
  );
}

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

# For Vite
VITE_SECRET_KEY="mamakochittel"

# For CRA
REACT_APP_SECRET_KEY="mamakochittel"

Tech Stack

Client: React, crypto-js

Features

  • set data in browser's localStorage with encrypted value
  • get data from browser's localStorage
  • remove data from browser's localStorage

Feedback

If you have any feedback, please reach out to me at [email protected]

Authors

License

MIT