Skip to content

Commit fa76650

Browse files
committed
Read me updated
1 parent 0ed7483 commit fa76650

File tree

1 file changed

+163
-1
lines changed

1 file changed

+163
-1
lines changed

README.md

Lines changed: 163 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,163 @@
1-
# caesar-cipher
1+
# GYKH - caesar-cipher
2+
3+
> One of the simplest forms of encryption
4+
5+
## Install
6+
7+
```
8+
$ npm install --save @gykh/caesar-cipher
9+
```
10+
### or
11+
12+
13+
```
14+
$ npm i -S @gykh/caesar-cipher
15+
```
16+
17+
## Usage
18+
19+
Encrypt and decrypt string
20+
21+
```js
22+
const { encryptString, decryptString } = require("@gykh/caesar-cipher");
23+
24+
...
25+
26+
const encrypted = encryptString(str, 3);
27+
28+
const decrypted = decryptString(encrypted, 3);
29+
30+
console.log(str === decrypted); // true
31+
```
32+
33+
Encrypt and decrypt buffer
34+
35+
```js
36+
const { encrypt, decrypt } = require("@gykh/caesar-cipher");
37+
const fs = require('fs');
38+
const { promisify } = require('util');
39+
const readFile = promisify(fs.readFile);
40+
41+
...
42+
43+
const encrypted = encrypt(await readFile(inputFile), 3);
44+
45+
const decrypted = decrypt(encrypted, 3);
46+
47+
console.log(buffer == decrypted); // true
48+
```
49+
50+
Encrypt and decrypt streams
51+
52+
```js
53+
const { EncryptTransform, DecryptTransform } = require("@gykh/caesar-cipher");
54+
const fs = require('fs');
55+
56+
...
57+
58+
const readStream = fs.createReadStream(inputFile);
59+
const writeStream = fs.createWriteStream(outputFile);
60+
61+
const encryptTransform = new EncryptTransform(3);
62+
const decryptTransform = new DecryptTransform(3);
63+
64+
const stream = readStream
65+
.pipe(encryptTransform)
66+
.pipe(decryptTransform)
67+
.pipe(writeStream)
68+
69+
stream.on("error", () => /* do something */);
70+
stream.on("finish", () => /* do something */);
71+
```
72+
73+
## API
74+
75+
### caesar-cipher
76+
77+
### .encryptString(input, key)
78+
79+
#### input
80+
81+
Type: `string`<br/>
82+
Required
83+
84+
#### key
85+
86+
Type: `number`<br/>
87+
Required
88+
89+
key should be a number between 1-26
90+
91+
### .decryptString(input, key)
92+
93+
#### input
94+
95+
Type: `string`<br/>
96+
Required
97+
98+
#### key
99+
100+
Type: `number`<br/>
101+
Required
102+
103+
key should be a number between 1-26
104+
105+
### .encrypt(input, key)
106+
107+
#### input
108+
109+
Type: `Buffer`<br/>
110+
Required
111+
112+
#### key
113+
114+
Type: `number`<br/>
115+
Required
116+
117+
key should be a number between 1-26
118+
119+
### .decrypt(input, key)
120+
121+
#### input
122+
123+
Type: `Buffer`<br/>
124+
Required
125+
126+
#### key
127+
128+
Type: `number`<br/>
129+
Required
130+
131+
key should be a number between 1-26
132+
133+
### new EncryptTransform(key)
134+
135+
#### key
136+
137+
Type: `number`<br/>
138+
Required
139+
140+
key should be a number between 1-26
141+
142+
### new DecryptTransform(key)
143+
144+
#### key
145+
146+
Type: `number`<br/>
147+
Required
148+
149+
key should be a number between 1-26
150+
151+
## Understand Caesar Cipher
152+
153+
> The Caesar cipher, also known as a shift cipher, is one of the simplest forms of encryption. It is a substitution cipher where each letter in the original message (called the plaintext) is replaced with a letter corresponding to a certain number of letters up or down in the alphabet. [Learn more](https://learncryptography.com/classical-encryption/caesar-cipher)
154+
155+
## Developer
156+
157+
- [Sylvester Das](https://www.sylvesterdas.com)
158+
159+
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/black_img.png)](https://www.buymeacoffee.com/sylvester.das)
160+
161+
## License
162+
163+
MIT © 2021 [get-your-knowledge-here](./LICENSE)

0 commit comments

Comments
 (0)