readme: Added example inline
This commit is contained in:
parent
2f7deacdb1
commit
23e1d52b04
32
README.md
32
README.md
|
@ -12,16 +12,42 @@ Run the following command in your project directory to add this library.
|
||||||
```sh
|
```sh
|
||||||
cargo add false-bottom
|
cargo add false-bottom
|
||||||
```
|
```
|
||||||
Or alternatively, check out the [crates.io](https://crates.io/crates/false-bottom) to add this library to your project using the `Cargo.toml` file.
|
Or alternatively, check out [crates.io](https://crates.io/crates/false-bottom) to add this library to your project using the `Cargo.toml` file.
|
||||||
The documentation is available at [docs.rs](https://docs.rs/false-bottom).
|
The documentation is available at [docs.rs](https://docs.rs/false-bottom).
|
||||||
|
|
||||||
## Run the examples
|
## Examples
|
||||||
These are provided in the [examples](./examples) directory.
|
These are provided in the [examples](https://codeberg.org/skran/false-bottom/src/branch/main/examples) directory.
|
||||||
Run them using the following command:
|
Run them using the following command:
|
||||||
```sh
|
```sh
|
||||||
cargo run --example <filename>
|
cargo run --example <filename>
|
||||||
```
|
```
|
||||||
|
### Encryption
|
||||||
|
```rust
|
||||||
|
use false_bottom::{FalseBottom, Fb128};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// Input messages
|
||||||
|
let msg1 = "Weather department warns of heavy rains within the upcoming two days";
|
||||||
|
let msg2 = "I have gathered intel regarding the government's illegal spying";
|
||||||
|
|
||||||
|
// Cipher initialization
|
||||||
|
let mut fb = Fb128::init(12, 12);
|
||||||
|
|
||||||
|
// Encryption (Adding messages is not limited to 2)
|
||||||
|
let key1 = fb.add(&msg1.as_bytes());
|
||||||
|
let key2 = fb.add(&msg2.as_bytes());
|
||||||
|
|
||||||
|
// Decryption
|
||||||
|
let decr1 = fb.decrypt(&key1).unwrap();
|
||||||
|
let decr2 = fb.decrypt(&key2).unwrap();
|
||||||
|
|
||||||
|
let result1 = String::from_utf8(decr1).unwrap();
|
||||||
|
let result2 = String::from_utf8(decr2).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(msg1, result1);
|
||||||
|
assert_eq!(msg2, result2);
|
||||||
|
}
|
||||||
|
```
|
||||||
## Todo
|
## Todo
|
||||||
- [x] Add more block sizes.
|
- [x] Add more block sizes.
|
||||||
- [ ] Add capabilities to edit and delete added messages in the ciphertext.
|
- [ ] Add capabilities to edit and delete added messages in the ciphertext.
|
||||||
|
|
Loading…
Reference in New Issue