# crypto-browser-storage

> ☢ A simple package for secure local storage data by encryption using Crypto.JS

Latest version **4.0.2** (published 2023-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install crypto-browser-storage
pnpm add crypto-browser-storage
yarn add crypto-browser-storage
bun add crypto-browser-storage
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.2 |
| Published | 2023-11-18 |
| First published | 2021-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 3 |
| Unpacked size | 34.8 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Sefat Anam |
| Maintainers | thesefatanam |
| Keywords | npm, angular, typescript, npm-package, localstorage, cryptojs |

## Links

- npm: https://www.npmjs.com/package/crypto-browser-storage
- npm.io page: https://npm.io/package/crypto-browser-storage

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0
- [crypto-js](https://npm.io/package/crypto-js.md) ^3.1.8
- [generate-js](https://npm.io/package/generate-js.md) ^3.1.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 4.0.2 (latest) — 2023-11-18
- 4.0.1 — 2023-11-18
- 4.0.0 — 2023-11-18
- 3.0.0 — 2023-06-29
- 2.1.0 — 2022-11-20
- 1.4.0 — 2022-11-20
- 1.1.42-beta — 2022-11-20
- 1.1.41-beta — 2022-11-20
- 2.0.3 — 2022-11-19
- 2.0.2 — 2022-11-19
- 2.0.1 — 2022-11-19
- 1.1.4 — 2022-11-19
- 2.0.0 — 2022-11-19
- 1.0.6 — 2022-11-19
- 1.0.5 — 2022-11-19
- … 4 more at https://npm.io/package/crypto-browser-storage/versions

## README

# Crypto Browser Storage
☢ A simple package for secure local storage data by encryption using Crypto.JS. Project generated with angular version ```12.2.0```, sou must need an Angular Project ( ``version >= 12.2.x`` )

## How to use
* Use ``npm i crypto-browser-storage``
* Inject to your component or service as Dependency Injection
* Then you will be able to access `crypto-browser-storage`'s library functions, 
    -   setCache
    -   getCache
    -   removeCacheByKey
    -   clearAllCache

<br>

## Angular Compatibility Version

- For `ng v12.x.x` use `npm i crypto-browser-storage@1.0.3`
- For `ng v14.x.x` use `npm i crypto-browser-storage@1.4.0`
- For `ng v15.x.x` use `npm i crypto-browser-storage@2.1.0`
- For `ng v16.x.x` use `npm i crypto-browser-storage@3.0.0`
- For `ng v17.x.x` use `npm i crypto-browser-storage@4.0.2`

## For Angular Version 17 (only) 🎉 

Now you can provide your custom encryption key. To provide your custom encryption key you have to follow this instruction.
Provide `CRYPTO_HASH_KEY` in `app.module.ts`. <br>
Example:

```
providers: [
    ....
    CryptoBrowserStorageService,
    { provide: CRYPTO_HASH_KEY, useValue: 'YOUR_KEY_HERE' }
  ]

```

<br>

## Sample Code Snippet
<br>


````
import { CryptoBrowserStorageService } from 'crypto-browser-storage';

export class AppComponent {

constructor(private cache: CryptoBrowserStorageService) {}


    tests() {
    
    this.cache.setCache("Posts1", [{"id": 1, "name": "Sample"}]);
    this.cache.setCache("Posts2", ["id", "name", "Sample"]);
    this.cache.setCache("Posts3", 3);
    this.cache.setCache("Posts5", {"id": 4, "name": "Sample"});
    
    // this.cache.removeCacheByKey("Posts1")
    
    console.log(this.cache.getCache("Posts1"))
    console.log(this.cache.getCache("Posts2"))
    console.log(this.cache.getCache("Posts3"))
    console.log(this.cache.getCache("Posts5"))

    this.cache.clearAllCache();
    
    }

}
````
### End result of the following ``tests()`` method is bellow,
<br>

![Screenshot 2021-10-30 204648](https://user-images.githubusercontent.com/37630292/139538058-0fa32585-bc84-4518-b6e9-cec7d38545a8.png)

![Screenshot 2021-10-30 205713](https://user-images.githubusercontent.com/37630292/139538317-9e63a3fd-fe0a-406e-9573-a215bf56a30d.png)

---
_Source: https://npm.io/package/crypto-browser-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
