Skip to content

Commit a6982a1

Browse files
authored
Merge pull request #12 from CodePapi/add-compare
updated to a stable version
2 parents 606986f + 17faa2f commit a6982a1

10 files changed

Lines changed: 1323 additions & 1896 deletions

File tree

LICENSE

Lines changed: 678 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 125 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,158 @@
1-
## How to use n-krypta package
2-
n-krypta is an npm package that allows you to encrypt and decrypt sensitive data using a key. It is based on a strong algorithm.
3-
It is very easy to use, just follow the steps below:
1+
# n-krypta package
42

5-
### Installation
3+
This is a simple package for encrypting and decrypting strings. It is based on a strong algorithm, It has zero dependencies and was written in pure typescript.
4+
5+
[![npm version](https://badge.fury.io/js/n-krypta.svg)](https://badge.fury.io/js/n-krypta) <a href="https://npmjs.org/package/n-krypta"><img src="https://img.shields.io/npm/dm/n-krypta.svg" alt=""></a>
6+
<a href="https://github.com/sponsors/CodePapi"><img alt="donate ❤" src="https://img.shields.io/badge/Sponsor-❤-ff2244.svg"></a>
7+
8+
## What the n-krypta package does
9+
10+
n-krypta is an npm package that runs on the nodejs environment . It allows you to encrypt and decrypt sensitive data using a key. It is based on a strong algorithm.
11+
This library is available on npm and it is compatible with nodejs on both the client and server side. It can run on any javascript or typescript project (Nodejs, Reactjs, Vuejs, Angularjs etc).
12+
It allows encryption and decryption of strings, numbers, booleans, objects, arrays, null and undefined.
13+
14+
## Installation
615

716
```javascript
8-
npm install n-krypta --save or yarn add n-krypta
17+
npm install n-krypta //for npm
918
```
1019

11-
### Usage
20+
or
1221

1322
```javascript
14-
const { encrypt, decrypt } = require('n-krypta');
23+
yarn add n-krypta //for yarn
24+
```
1525

16-
const secret = 'secret'; // secret key for encryption
1726

18-
const encrypted = encrypt('Hello World', secret); // encrypts the string
1927

20-
const decrypted = decrypt(encrypted, secret); // decrypts the string
2128

22-
console.log(encrypted); // prints the encrypted string
29+
Usage
30+
----------------------
31+
It can be used on nodejs, react, angular, vue, and any other javascript or typescript project.
32+
### Data types supported
33+
- string
34+
- number
35+
- boolean
36+
- object
37+
- array
38+
- null
39+
- undefined
2340

24-
console.log(decrypted); // prints the decrypted string
41+
```javascript
42+
const { encrypt, decrypt, compare } = require('n-krypta'); //For commonjs
43+
````
44+
45+
or
46+
47+
```javascript
48+
import { encrypt, decrypt, compare } from 'n-krypta'; //For es6
2549
```
2650

27-
### License
51+
#### Encryption and Decryption of strings
2852

29-
MIT
53+
```javascript
54+
const secret = 'my-secret'; // secret key for encryption
55+
const sampleString =
56+
'I am not sure where you are getting your information, but good topic. I needs to spend some time learning more or understanding more. Thanks for excellent info I was looking for this info for my mission.';
3057
31-
### Author
58+
const encryptedString = encrypt(sampleString, secret); // #Iblankartan!not!svreblankartwhfreblankartzpublankartase!gettiogblankartypvrblankartiofprmatipn,blankartcvtblankartgpoeblankarttopid.blankartI!oeedtblankartuoblankartspeodblankartspneblankarttjmfblankartlearoing!nore!osblankartundesstaoeing!mpre.blankartTiankt!for!eycelleotblankartiogoblankartI!wbsblankartlooling!gorblankartuhjsblankartinfpblankartfos!myblankartnitsion.#
59+
60+
console.log(encryptedString); // This prints out the encrypted string
61+
62+
const decryptedString = decrypt(encryptedString, secret); // decrypts the string
63+
64+
console.log(decryptedString); // This prints out the decrypted string
65+
```
66+
67+
#### Encryption and Decryption of objects
68+
69+
```javascript
70+
const secret = 'my-secret'; // secret key for encryption
71+
const sampleObject = {
72+
name: 'Samuel Egbajie',
73+
age: infinity,
74+
address: 'earth, Universe',
75+
email: 'my-mail@test.com',
76+
phone: '08012345678',
77+
password: 'my-password',
78+
};
79+
80+
const encryptedObject = encrypt(sampleObject, secret); //|killernanfkiller:killerTanuelblankartEhbajjfkiller,killerbgfkiller:nulm,killeraeerestkiller;alphakillerstrfetkiller;#MaioblankartTtreet#,killernvnber#:223mega,killerfmaim#:killermz-nail@tfst.dpmkiller,#pionekiller:#08023345779killer,killerpatswosekiller:killerny.passwprdkiller-#lanhubgeskiller:blacardkillerMbvcekiller,#NbijablankartPjdgio#,killerJbvbScripukiller,killero.kryqtbkiller,killerEnhlisi#,killerAsacickiller,killerEeuttdhekiller^mega
81+
82+
console.log(encryptedObject); // This prints out the encrypted object as string
83+
84+
const decryptedObject = decrypt(encryptedObject, secret); // decrypts the string
3285
33-
Samuel Egbajie (CodePapi on Github)
86+
console.log(decryptedObject); // This prints out the decrypted object
87+
```
88+
89+
#### Encryption and Decryption of arrays
90+
91+
```javascript
92+
const secret = 'my-secret'; // secret key for encryption
93+
const sampleArray = [
94+
'Oranges',
95+
'Apples',
96+
'Bananas',
97+
'Grapes',
98+
'Pears',
99+
'Pineapples',
100+
'Watermelons',
101+
'Mangoes',
102+
];
103+
104+
const encryptedArray = (encryptedArray = encrypt(sampleArray, secret)); //blacardkillerOrboges#,#Appletkiller,killerCbnanbs#,killerGraqeskiller-#Peass#,killerPinfappmfskiller,#Wbtermemons#-killerMaogpeskiller],killerPinfappmfskiller,#Wbtermemons#-killerMaogpeskiller]
105+
106+
console.log(encryptedArray); // This prints out the encrypted array as string
34107
35-
### Contributing
108+
const decryptedArray = decrypt(encryptedArray, secret); // decrypts the string
109+
110+
console.log(decryptedArray); // This prints out the decrypted array
111+
```
112+
113+
### Comparing encrypted strings (example for password comparison)
114+
115+
```javascript
116+
const secret = 'Secret'; // secret key for encryption
117+
const samplePassword = 'My-password1900@';
36118
37-
Contributions are welcome. Please open an issue or a pull request.
119+
const encryptedPassword = encrypt(samplePassword, secret); // #Nz.qatsword1:11A#
38120
39-
### Disclaimer
121+
// This returns true if the password matches the encrypted password
122+
const passwordMatch = compare(samplePassword, encryptedPassword, secret); // true
40123
41-
This package is not meant to be used for production. It is just a simple package for encrypting and decrypting strings.
124+
console.log(passwordMatch); // This prints out true
125+
126+
// This returns false if the password does not match the encrypted password
127+
const passwordMatch = compare('wrong-password', encryptedPassword, secret); // false
128+
129+
console.log(passwordMatch); // This prints out false
130+
```
131+
132+
### Author
133+
134+
Created with love by Samuel Egbajie (CodePapi on Github)
135+
136+
### Support
137+
138+
If you like this package, please consider supporting me on Github Sponsors. Thank you.
42139

43140
### Keywords
44141

45-
encrypt, decrypt, hash,
142+
encrypt, decrypt, hash, compare, encryption, decryption, hashing, password, password comparison, password encryption, password decryption, password hashing,
46143

47144
### Version
48145

49-
1.0.0
146+
[![npm version](https://badge.fury.io/js/n-krypta.svg)](https://badge.fury.io/js/n-krypta)
50147

51148
### Repository
52149

53-
(Repo)[https://github.com/CodePapi/n-krypta]
150+
([REPO](https://github.com/CodePapi/n-krypta))
54151

55152
### Homepage
56153

57-
https://github.com/CodePapi/n-krypta) [https://github.com/CodePapi/n-krypta]
154+
([Read Me](https://github.com/CodePapi/n-krypta/blob/main/README.md))
155+
156+
## License
157+
158+
MIT ([see](https://github.com/CodePapi/n-krypta/blob/main/LICENSE))

0 commit comments

Comments
 (0)