@@ -11,6 +11,105 @@ const ciphertext = aesWrapper.aes128Encrypt(aesKey, aesNonce, tohashBytes);
11
11
const plaintxt = aesWrapper .aes128Decrypt (aesKey , aesNonce , ciphertext );
12
12
```
13
13
14
+ ### Asymmetric
15
+ -RSA
16
+ ``` typescript
17
+ const rsaWrapper: RSAWrapper = new RSAWrapper ();
18
+ const keys: RsaKeyPairResult = rsaWrapper .generateKeys (4096 );
19
+ const tohashed: string = " This is my array to encrypt" ;
20
+ const encoder = new TextEncoder ();
21
+ const tohashBytes: Array <number > = Array .from (encoder .encode (tohashed ));
22
+ const ciphertext = rsaWrapper .encrypt (keys .publicKey , tohashBytes );
23
+ const plaintext = rsaWrapper .decrypt (keys .privateKey , ciphertext );
24
+ ```
25
+
26
+
27
+ ### Digital Signature
28
+ -ED25519 SHA
29
+ ``` typescript
30
+ const shaDsWrapper = DigitalSignatureFactory .get (DigitalSignatureType .SHA256 )
31
+ const toHash: string = " This is my array to encrypt" ;
32
+ const encoder = new TextEncoder ();
33
+ const toHashBytes: Array <number > = Array .from (encoder .encode (toHash ));
34
+ const dsResult = shaDsWrapper .createED25519 (toHashBytes );
35
+ const verify = shaDsWrapper .verifyED25519 (dsResult .publicKey , toHashBytes , dsResult .signature );
36
+ ```
37
+
38
+ -RSA SHA
39
+ ``` typescript
40
+ const shaDsWrapper = DigitalSignatureFactory .get (DigitalSignatureType .SHA512 )
41
+ const tohashed: string = " This is my array to encrypt" ;
42
+ const notOriginal: string = " This is not a fun time" ;
43
+ const encoder = new TextEncoder ();
44
+ const tohashBytes: Array <number > = Array .from (encoder .encode (tohashed ));
45
+ const badBytes: Array <number > = Array .from (encoder .encode (notOriginal ));
46
+ const dsResult: RSADigitalSignatureResult = shaDsWrapper .createRsa (4096 , tohashBytes );
47
+ const verify = shaDsWrapper .verifyRSa (dsResult .publicKey , badBytes , dsResult .signature );
48
+ ```
49
+
50
+
51
+ ### Hashers
52
+ -SHA3 512
53
+ ``` typescript
54
+ const wrapper = new SHAWrapper ();
55
+ const tohashed: string = " This is my array to hash" ;
56
+ const encoder = new TextEncoder ();
57
+ const tohashBytes: Array <number > = Array .from (encoder .encode (tohashed ));
58
+ const hashed = wrapper .hash512 (tohashBytes );
59
+ ```
60
+
61
+ -SHA3 256
62
+ ``` typescript
63
+ const wrapper = new SHAWrapper ();
64
+ const tohashed: string = " This is my array to hash" ;
65
+ const encoder = new TextEncoder ();
66
+ const tohashBytes: Array <number > = Array .from (encoder .encode (tohashed ));
67
+ const hashed = wrapper .hash256 (tohashBytes );
68
+ ```
69
+
70
+ ### Hybrid Encryption
71
+ -AES/RSA Encryption
72
+ ``` typescript
73
+ const hybridWrapper = new HybridEncryptionWrapper ();
74
+ let initalizer = new AESRSAHybridInitializer (128 , 4096 );
75
+ const tohashed: string = " This is my encrypt text for rsa hybrid" ;
76
+ const encoder = new TextEncoder ();
77
+ const toEncrypt: Array <number > = Array .from (encoder .encode (tohashed ));
78
+ let result: AesRsaHybridEncryptResult = hybridWrapper .encrypt (toEncrypt , initalizer );
79
+ let plaintext: Array <number > = hybridWrapper .decrypt (initalizer .rsaKeyPair .privateKey , result );
80
+ ```
81
+
82
+ ### Key Exchange
83
+ -X25519
84
+ ``` typescript
85
+ const wrapper = new X25519Wrapper ();
86
+ const alice = wrapper .generateSecretAndPublicKey ();
87
+ const bob = wrapper .generateSecretAndPublicKey ();
88
+
89
+ const alice_shared_secret = wrapper .generateSharedSecret (
90
+ alice .secretKey ,
91
+ bob .publicKey ,
92
+ );
93
+ const bob_shared_secret = wrapper .generateSharedSecret (
94
+ bob .secretKey ,
95
+ alice .publicKey ,
96
+ );
97
+
98
+ var result = areEqual (alice_shared_secret , bob_shared_secret );
99
+ ```
100
+
101
+ ### Sponges
102
+ -Ascon 128
103
+ ``` typescript
104
+ const wrapper: AsconWrapper = new AsconWrapper ();
105
+ const key: Array <number > = wrapper .ascon128Key ();
106
+ const nonce: Array <number > = wrapper .ascon128Nonce ();
107
+ const tohashed: string = " This is my array to encrypt" ;
108
+ const encoder = new TextEncoder ();
109
+ const tohashBytes: Array <number > = Array .from (encoder .encode (tohashed ));
110
+ const ciphertext = wrapper .ascon128Encrypt (key , nonce , tohashBytes );
111
+ const plaintext = wrapper .ascon128Decrypt (key , nonce , ciphertext );
112
+ ```
14
113
15
114
### Passwords
16
115
- BCrypt
0 commit comments