File tree Expand file tree Collapse file tree 7 files changed +0
-153
lines changed Expand file tree Collapse file tree 7 files changed +0
-153
lines changed Original file line number Diff line number Diff line change @@ -23,29 +23,6 @@ Add this to your `Cargo.toml`:
23
23
abcrypt = " 0.3.6"
24
24
```
25
25
26
- ### Example
27
-
28
- ``` rust
29
- use abcrypt :: Params ;
30
-
31
- let data = b " Hello, world!\ n" ;
32
- let passphrase = " passphrase" ;
33
-
34
- // Encrypt `data` using `passphrase`.
35
- let ciphertext = abcrypt :: encrypt (data , passphrase ). unwrap ();
36
- assert_ne! (ciphertext , data );
37
-
38
- // And extract the Argon2 parameters from it.
39
- let params = Params :: new (& ciphertext ). unwrap ();
40
- assert_eq! (params . memory_cost (), 19456 );
41
- assert_eq! (params . time_cost (), 2 );
42
- assert_eq! (params . parallelism (), 1 );
43
-
44
- // And decrypt it back.
45
- let plaintext = abcrypt :: decrypt (ciphertext , passphrase ). unwrap ();
46
- assert_eq! (plaintext , data );
47
- ```
48
-
49
26
### Crate features
50
27
51
28
#### ` alloc `
Original file line number Diff line number Diff line change @@ -26,31 +26,6 @@ To install this library:
26
26
pip install abcrypt-py
27
27
```
28
28
29
- ### Example
30
-
31
- ``` py
32
- from typing import Final
33
-
34
- import abcrypt_py
35
-
36
- DATA : Final[bytes ] = b " Hello, world!\n "
37
- PASSPHRASE : Final[bytes ] = b " passphrase"
38
-
39
- # Encrypt `DATA` using `PASSPHRASE`.
40
- ciphertext = abcrypt_py.encrypt(DATA , PASSPHRASE )
41
- assert ciphertext != DATA
42
-
43
- # And extract the Argon2 parameters from it.
44
- params = abcrypt_py.Params(ciphertext)
45
- assert params.memory_cost == 19456
46
- assert params.time_cost == 2
47
- assert params.parallelism == 1
48
-
49
- # And decrypt it back.
50
- plaintext = abcrypt_py.decrypt(ciphertext, PASSPHRASE )
51
- assert plaintext == DATA
52
- ```
53
-
54
29
### Documentation
55
30
56
31
See the [ documentation] [ docs-url ] for more details.
Original file line number Diff line number Diff line change @@ -35,31 +35,6 @@ wasm-pack build
35
35
36
36
This will generate build artifacts in the ` pkg ` directory.
37
37
38
- ### Example
39
-
40
- ``` ts
41
- import * as assert from " jsr:@std/assert" ;
42
-
43
- import * as abcrypt from " ./pkg/abcrypt_wasm.js" ;
44
-
45
- const data = new TextEncoder ().encode (" Hello, world!\n " );
46
- const passphrase = new TextEncoder ().encode (" passphrase" );
47
-
48
- // Encrypt `data` using `passphrase`.
49
- const ciphertext = abcrypt .encrypt (data , passphrase );
50
- assert .assertNotEquals (ciphertext , data );
51
-
52
- // And extract the Argon2 parameters from it.
53
- const params = new abcrypt .Params (ciphertext );
54
- assert .assertEquals (params .memoryCost , 19456 );
55
- assert .assertEquals (params .timeCost , 2 );
56
- assert .assertEquals (params .parallelism , 1 );
57
-
58
- // And decrypt it back.
59
- const plaintext = abcrypt .decrypt (ciphertext , passphrase );
60
- assert .assertEquals (plaintext , data );
61
- ```
62
-
63
38
### Documentation
64
39
65
40
See the [ documentation] [ docs-url ] for more details.
Original file line number Diff line number Diff line change 5
5
.Library
6
6
* xref:index.adoc[Introduction]
7
7
* xref:usage.adoc[]
8
- * xref:examples.adoc[]
9
8
* https://docs.rs/abcrypt[API Reference]
10
9
* xref:changelog.adoc[]
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11
11
----
12
12
pip install abcrypt-py
13
13
----
14
-
15
- == Example
16
-
17
- [source,py]
18
- ----
19
- from typing import Final
20
-
21
- import abcrypt_py
22
-
23
- DATA: Final[bytes] = b"Hello, world!\n"
24
- PASSPHRASE: Final[bytes] = b"passphrase"
25
-
26
- # Encrypt `DATA` using `PASSPHRASE`.
27
- ciphertext = abcrypt_py.encrypt(DATA, PASSPHRASE)
28
- assert ciphertext != DATA
29
-
30
- # And extract the Argon2 parameters from it.
31
- params = abcrypt_py.Params(ciphertext)
32
- assert params.memory_cost == 19456
33
- assert params.time_cost == 2
34
- assert params.parallelism == 1
35
-
36
- # And decrypt it back.
37
- plaintext = abcrypt_py.decrypt(ciphertext, PASSPHRASE)
38
- assert plaintext == DATA
39
- ----
Original file line number Diff line number Diff line change @@ -23,29 +23,3 @@ wasm-pack build
23
23
----
24
24
25
25
This will generate build artifacts in the `pkg` directory.
26
-
27
- == Example
28
-
29
- [source,ts]
30
- ----
31
- import * as assert from "jsr:@std/assert";
32
-
33
- import * as abcrypt from "./pkg/abcrypt_wasm.js";
34
-
35
- const data = new TextEncoder().encode("Hello, world!\n");
36
- const passphrase = new TextEncoder().encode("passphrase");
37
-
38
- // Encrypt `data` using `passphrase`.
39
- const ciphertext = abcrypt.encrypt(data, passphrase);
40
- assert.assertNotEquals(ciphertext, data);
41
-
42
- // And extract the Argon2 parameters from it.
43
- const params = new abcrypt.Params(ciphertext);
44
- assert.assertEquals(params.memoryCost, 19456);
45
- assert.assertEquals(params.timeCost, 2);
46
- assert.assertEquals(params.parallelism, 1);
47
-
48
- // And decrypt it back.
49
- const plaintext = abcrypt.decrypt(ciphertext, passphrase);
50
- assert.assertEquals(plaintext, data);
51
- ----
You can’t perform that action at this time.
0 commit comments