https://github.com/dfa1234/ngx-simple-crypt
Angular module for encryption through XOR cipher method
https://github.com/dfa1234/ngx-simple-crypt
angular encryption webpack
Last synced: 12 months ago
JSON representation
Angular module for encryption through XOR cipher method
- Host: GitHub
- URL: https://github.com/dfa1234/ngx-simple-crypt
- Owner: dfa1234
- Created: 2017-08-27T08:13:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-13T18:10:12.000Z (over 8 years ago)
- Last Synced: 2025-04-11T19:43:18.446Z (12 months ago)
- Topics: angular, encryption, webpack
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/ngx-simple-crypt
- Size: 12.7 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## ngx-simple-crypt
Javascript module (compatible with any angular version, but not limited to angular) for encryption through XOR cipher method.
Useful for hiding non sensitive informations, like code obfuscations, QR code datas, etc...
### Import
```sh
npm i ngx-simple-crypt
```
or
```sh
yarn add ngx-simple-crypt
```
### Usage
No module import needed, you can use anywhere:
```javascript
import {SimpleCrypt} from "ngx-simple-crypt";
```
```javascript
let simpleCrypt = new SimpleCrypt();
let encodedString = simpleCrypt.encode("my-key","You are not supposed to read this");
console.log(encodedString);// "NBZYSwQLCFlDBBFZHgxdGwoKCB0NHwpZHxxMD0UNBRBe"
let decodedString = simpleCrypt.decode("my-key",encodedString);
console.log(decodedString);// "You are not supposed to read this"
```
You can also use the static methods for encoding/decoding Objects directly:
```javascript
let encodedObjectAsString:string = SimpleCrypt.encodeDefault("my-key", {data:'very important stuff'});
let object:{} = SimpleCrypt.decodeDefault("my-key", encodedObjectAsString);
```
From [wikipedia](https://en.wikipedia.org/wiki/XOR_cipher):
*The XOR operator is extremely common as a component in more complex ciphers. By itself, using a constant repeating key, a simple XOR cipher can trivially be broken using frequency analysis. If the content of any message can be guessed or otherwise known then the key can be revealed. Its primary merit is that it is simple to implement, and that the XOR operation is computationally inexpensive. A simple repeating XOR (i.e. using the same key for xor operation on the whole data) cipher is therefore sometimes used for hiding information in cases where no particular security is required.*