mol_crypto2_lib 0.0.1

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/.nojekyll ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # $mol_crypto2
2
+
3
+ Simple API for effective cross platform cryptography with minimal extra size.
4
+
5
+ ## Signing & Verifying
6
+
7
+ - Auditor - public key for sign verification.
8
+ - Signer - private key for signing. Can be used as Auditor.
9
+
10
+ ```typescript
11
+ const Alice = await $mol_crypto2_signer.generate() // 64 B
12
+ const Bella = await $mol_crypto2_signer.generate() // 64 B
13
+
14
+ const data = new Uint8Array([ 1, 2, 3 ]) // 3 B
15
+ const digest = $mol_crypto_hash( data ) // 20 B
16
+ const sign = await Alice.sign( digest ) // 64 B
17
+
18
+ const auditor = Alice.auditor() // 32 B
19
+ const verified = await auditor.verify( digest, sign ) // true
20
+ ```
21
+
22
+ ## Encryption & Decryption
23
+
24
+ - Socket - public key for encryption/decryption.
25
+ - Cipher - private key for encryption/decryption. Can be used as Socket.
26
+
27
+ ```typescript
28
+ const Alice = await $mol_crypto2_cipher.generate() // 64 B
29
+ const Bella = await $mol_crypto2_cipher.generate() // 64 B
30
+
31
+ const secret = Bella.secret( Alice.socket() ) // 16 B
32
+ // const secret = Alice.secret( Bella.socket() ) // same
33
+
34
+ const data = new Uint8Array([ 1, 2, 3 ]) // 3 B
35
+ const salt = $mol_crypto_salt() // 16 B
36
+
37
+ const closed = await secret.encrypt( data, salt ) // 16 B
38
+ const opened = await secret.decrypt( closed, salt ) // 3 B
39
+ ```
40
+
41
+ ## Signing & Verifying & Encryption & Decryption
42
+
43
+ ```typescript
44
+ const Alice = await $mol_crypto2_private.generate() // 128 B
45
+ const Bella = await $mol_crypto2_private.generate() // 128 B
46
+
47
+ const secret = await Alice.cipher().secret( Bella.socket() ) // 16 B
48
+ // const secret = await Bella.cipher().secret( Alice.socket() ) // same
49
+
50
+ const data = new Uint8Array([ 1, 2, 3 ]) // 3 B
51
+ const salt = $mol_crypto_salt() // 16 B
52
+
53
+ const closed = await secretA.encrypt( data, salt ) // 16 B
54
+ const digest = $mol_crypto_hash( closed ) // 20 B
55
+ const sign = await Alice.signer().sign( digest ) // 64 B
56
+
57
+ const auditor = Alice.auditor() // 32 B
58
+ const verified = await auditor.verify( digest, sign ) ) // true
59
+ const opened = await secretA.decrypt( closed, salt ) ) // 3 B
60
+ ```
61
+
62
+ # Usage from NPM
63
+
64
+ ```
65
+ npm install mol_crypto2_lib
66
+ ```
67
+
68
+ [![](https://badgen.net/bundlephobia/minzip/mol_crypto2_lib)](https://bundlephobia.com/package/mol_crypto2_lib)
69
+
70
+ ```javascript
71
+ export { $mol_crypto2_private, default as $ } from "mol_crypto2_lib"
72
+ ```
package/manifest.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "mol_crypto2_lib",
3
+ "short_name": "mol_crypto2_lib",
4
+ "description": "",
5
+ "id": "mol_crypto2_lib",
6
+ "start_url": ".",
7
+ "display": "standalone",
8
+ "background_color": "#000000",
9
+ "theme_color": "#000000"
10
+ }
package/node.audit.js ADDED
@@ -0,0 +1,2 @@
1
+ console.info( `%cplace: $mol_build
2
+ message: Audit passed`, 'color:forestgreen; font-weight:bolder' )