Skip to content

Commit

Permalink
docs: Remove examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Oct 14, 2024
1 parent 37f9a6d commit bf999f2
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 106 deletions.
24 changes: 0 additions & 24 deletions crates/scryptenc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,6 @@ Add this to your `Cargo.toml`:
scryptenc = "0.9.8"
```

### Example

```rust
use scryptenc::Params;

let data = b"Hello, world!\n";
let passphrase = "passphrase";

// Encrypt `data` using `passphrase`.
let ciphertext = scryptenc::encrypt(data, passphrase);
assert_ne!(ciphertext, data);

// And extract the scrypt parameters from it.
let params = Params::new(&ciphertext).unwrap();
assert_eq!(params.log_n(), 17);
assert_eq!(params.n(), u64::pow(2, 17));
assert_eq!(params.r(), 8);
assert_eq!(params.p(), 1);

// And decrypt it back.
let plaintext = scryptenc::decrypt(ciphertext, passphrase).unwrap();
assert_eq!(plaintext, data);
```

### Crate features

#### `alloc`
Expand Down
26 changes: 0 additions & 26 deletions crates/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,6 @@ wasm-pack build

This will generate build artifacts in the `pkg` directory.

### Example

```ts
import * as assert from "jsr:@std/assert";

import * as scryptenc from "./pkg/scryptenc_wasm.js";

const data = new TextEncoder().encode("Hello, world!\n");
const passphrase = new TextEncoder().encode("passphrase");

// Encrypt `data` using `passphrase`.
const ciphertext = scryptenc.encrypt(data, passphrase);
assert.assertNotEquals(ciphertext, data);

// And extract the scrypt parameters from it.
const params = new scryptenc.Params(ciphertext);
assert.assertEquals(params.logN, 17);
assert.assertEquals(params.n, BigInt(2 ** 17));
assert.assertEquals(params.r, 8);
assert.assertEquals(params.p, 1);

// And decrypt it back.
const plaintext = scryptenc.decrypt(ciphertext, passphrase);
assert.assertEquals(plaintext, data);
```

### Documentation

See the [documentation][docs-url] for more details.
Expand Down
1 change: 0 additions & 1 deletion docs/book/modules/lib/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
.Library
* xref:index.adoc[Introduction]
* xref:usage.adoc[]
* xref:examples.adoc[]
* https://docs.rs/scryptenc[API Reference]
* xref:changelog.adoc[]
28 changes: 0 additions & 28 deletions docs/book/modules/lib/pages/examples.adoc

This file was deleted.

27 changes: 0 additions & 27 deletions docs/book/modules/wasm/pages/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,3 @@ wasm-pack build
----

This will generate build artifacts in the `pkg` directory.

== Example

[source,ts]
----
import * as assert from "jsr:@std/assert";
import * as scryptenc from "./pkg/scryptenc_wasm.js";
const data = new TextEncoder().encode("Hello, world!\n");
const passphrase = new TextEncoder().encode("passphrase");
// Encrypt `data` using `passphrase`.
const ciphertext = scryptenc.encrypt(data, passphrase);
assert.assertNotEquals(ciphertext, data);
// And extract the scrypt parameters from it.
const params = new scryptenc.Params(ciphertext);
assert.assertEquals(params.logN, 17);
assert.assertEquals(params.n, BigInt(2 ** 17));
assert.assertEquals(params.r, 8);
assert.assertEquals(params.p, 1);
// And decrypt it back.
const plaintext = scryptenc.decrypt(ciphertext, passphrase);
assert.assertEquals(plaintext, data);
----

0 comments on commit bf999f2

Please sign in to comment.