@sequencemedia/crypto 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +102 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # @sequencemedia/crypto
2
+
3
+ Encrypt and decrypt in Node and Bash
4
+
5
+ ## Node
6
+
7
+ Exports two functions, `encrypt` and `decrypt`
8
+
9
+ ```javascript
10
+ import {
11
+ encrypt,
12
+ decrypt
13
+ } from '@sequencemedia/crypto'
14
+ ```
15
+
16
+ ### `encrypt`
17
+
18
+ ```typescript
19
+ function encrypt(buffer: Buffer, secret: string, bytes?: number, algorithm?: string): Buffer
20
+ ```
21
+
22
+ Only `buffer` and `secret` are _required_
23
+
24
+ - `buffer` is the data to encrypt
25
+ - `secret` is the secret key to use for encryption
26
+
27
+ Both `bytes` and `algorithm` are _optional_
28
+
29
+ - `bytes` is the number of random bytes to use for the encryption _initialisation vector_. The default is `16`
30
+ - `algorithm` is the algorithm to use for encryption. The default is `aes-256-ctr`
31
+
32
+ ### `decrypt`
33
+
34
+ ```typescript
35
+ function decrypt(buffer: Buffer, secret: string, bytes?: number, algorithm?: string): Buffer
36
+ ```
37
+
38
+ Only `buffer` and `secret` are _required_
39
+
40
+ - `buffer` is the data to decrypt
41
+ - `secret` is the secret key to use for decryption
42
+
43
+ Both `bytes` and `algorithm` are _optional_
44
+
45
+ - `bytes` is the number of bytes to slice from the buffer for the decryption _initialisation vector_. The default is `16`
46
+ - `algorithm` is the algorithm to use for decryption. The default is `aes-256-ctr`
47
+
48
+ ## Bash
49
+
50
+ Exports two functions, `encrypt` and `decrypt`
51
+
52
+ ```bash
53
+ source ./crypto.sh
54
+ ```
55
+
56
+ ### `encrypt`
57
+
58
+ Requires `CRYPTO_KEY` as a _variable_ in the Bash environment and a file path to _encrypt_
59
+
60
+ ```bash
61
+ encrypted_file_data=$(encrypt "./file.txt")
62
+ ```
63
+
64
+ ```bash
65
+ encrypt "./file.txt" > "./encrypted.txt"
66
+ ```
67
+
68
+ ### `decrypt`
69
+
70
+ Requires `CRYPTO_KEY` as a _variable_ in the Bash environment and a file path to _decrypt_
71
+
72
+ ```bash
73
+ file_data=$(decrypt "./encrypted.txt")
74
+ ```
75
+
76
+ ```bash
77
+ decrypt "./encrypted.txt" > "./file.txt"
78
+ ```
79
+
80
+ ## Bash utilities
81
+
82
+ ### `encrypt.sh`
83
+
84
+ Requires `CRYPTO_KEY` as a _variable_ in the Bash environment
85
+
86
+ - A file _origin_ path for data to _encrypt_
87
+ - A file _destination_ path to put the encrypted data
88
+
89
+ ```bash
90
+ CRYPTO_KEY='secret' ./encrypt.sh --origin "./file.txt" --destination "./encrypted.txt"
91
+ ```
92
+
93
+ ### `decrypt.sh`
94
+
95
+ Requires `CRYPTO_KEY` as a _variable_ in the Bash environment
96
+
97
+ - A file _origin_ path for data to _decrypt_
98
+ - A file _destination_ path to put the decrypted data
99
+
100
+ ```bash
101
+ CRYPTO_KEY='secret' ./decrypt.sh --origin "./encrypted.txt" --destination "./file.txt"
102
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequencemedia/crypto",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "main": "./lib/index.cjs",
5
5
  "type": "module",
6
6
  "types": "./crypto.d.ts",