libsodium 0.7.15 → 0.7.16
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.
- package/LICENSE +1 -1
- package/README.md +17 -9
- package/dist/modules/libsodium.js +110 -1
- package/dist/modules-esm/libsodium.mjs +143 -0
- package/package.json +13 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
The [sodium](https://github.com/jedisct1/libsodium) crypto library
|
|
6
6
|
compiled to WebAssembly and pure JavaScript using
|
|
7
|
-
[Emscripten](https://github.com/
|
|
7
|
+
[Emscripten](https://github.com/emscripten-core/emscripten), with
|
|
8
8
|
automatically generated wrappers to make it easy to use in web
|
|
9
9
|
applications.
|
|
10
10
|
|
|
@@ -43,11 +43,15 @@ It contains code for commonly used functions.
|
|
|
43
43
|
is a superset of the previous script, that contains all functions,
|
|
44
44
|
including rarely used ones and undocumented ones.
|
|
45
45
|
- [modules](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules)
|
|
46
|
-
includes commonly used functions, and is designed to be loaded as a module.
|
|
46
|
+
includes commonly used functions, and is designed to be loaded as a CommonJS module.
|
|
47
47
|
`libsodium-wrappers` is the module your application should load, which
|
|
48
48
|
will in turn automatically load `libsodium` as a dependency.
|
|
49
49
|
- [modules-sumo](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules-sumo)
|
|
50
50
|
contains sumo variants of the previous modules.
|
|
51
|
+
- [modules-esm](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules-esm)
|
|
52
|
+
contains ESM (ES modules) versions with `.mjs` extensions.
|
|
53
|
+
- [modules-sumo-esm](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules-sumo-esm)
|
|
54
|
+
contains sumo ESM variants.
|
|
51
55
|
|
|
52
56
|
The modules are also available on npm:
|
|
53
57
|
- [libsodium-wrappers](https://www.npmjs.com/package/libsodium-wrappers)
|
|
@@ -93,7 +97,7 @@ await (async() => {
|
|
|
93
97
|
|
|
94
98
|
The `sodium.js` file includes both the core libsodium functions, as
|
|
95
99
|
well as the higher-level JavaScript wrappers. It can be loaded
|
|
96
|
-
|
|
100
|
+
asynchronously.
|
|
97
101
|
|
|
98
102
|
A `sodium` object should be defined in the global namespace, with the
|
|
99
103
|
following property:
|
|
@@ -159,7 +163,11 @@ let key = sodium.from_hex('724b092810ec86d7e35c9d067702b31ef90bc43a7b59862674991
|
|
|
159
163
|
|
|
160
164
|
function encrypt_and_prepend_nonce(message) {
|
|
161
165
|
let nonce = sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES);
|
|
162
|
-
|
|
166
|
+
let ciphertext = sodium.crypto_secretbox_easy(message, nonce, key);
|
|
167
|
+
let result = new Uint8Array(nonce.length + ciphertext.length);
|
|
168
|
+
result.set(nonce);
|
|
169
|
+
result.set(ciphertext, nonce.length);
|
|
170
|
+
return result;
|
|
163
171
|
}
|
|
164
172
|
|
|
165
173
|
function decrypt_after_extracting_nonce(nonce_and_ciphertext) {
|
|
@@ -185,13 +193,13 @@ returns the following object:
|
|
|
185
193
|
|
|
186
194
|
### Standard vs Sumo version
|
|
187
195
|
|
|
188
|
-
The standard version (in the `dist/browsers
|
|
189
|
-
directories) contains the high-level functions, and
|
|
190
|
-
one for most projects.
|
|
196
|
+
The standard version (in the `dist/browsers`, `dist/modules`, and
|
|
197
|
+
`dist/modules-esm` directories) contains the high-level functions, and
|
|
198
|
+
is the recommended one for most projects.
|
|
191
199
|
|
|
192
200
|
Alternatively, the "sumo" version, available in the
|
|
193
|
-
`dist/browsers-sumo` and `dist/modules-sumo`
|
|
194
|
-
the symbols from the original library. This includes undocumented,
|
|
201
|
+
`dist/browsers-sumo`, `dist/modules-sumo`, and `dist/modules-sumo-esm`
|
|
202
|
+
directories contains all the symbols from the original library. This includes undocumented,
|
|
195
203
|
untested, deprecated, low-level and easy to misuse functions.
|
|
196
204
|
|
|
197
205
|
The `crypto_pwhash_*` function set is only included in the sumo version.
|