Crates.io | crypt4gh |
lib.rs | crypt4gh |
version | 0.4.1 |
source | src |
created_at | 2020-11-06 08:37:56.084779 |
updated_at | 2022-05-02 12:45:26.818393 |
description | Encryption and decryption implementation of the Crypt4GH encryption format. |
homepage | |
repository | https://github.com/EGA-archive/crypt4gh-rust |
max_upload_size | |
id | 309142 |
size | 2,715,482 |
Rust implementation for the Crypt4GH encryption format.
Requirements: Rust
cargo install crypt4gh
In the releases page, You can find compiled binaries for:
Utility for the cryptographic GA4GH standard, reading from stdin and outputting to stdout.
USAGE:
crypt4gh [FLAGS] [SUBCOMMAND]
FLAGS:
-h, --help Prints help information
-v, --verbose Sets the level of verbosity
-V, --version Prints version information
SUBCOMMANDS:
decrypt Decrypts the input using your secret key and the (optional) public key of the sender.
encrypt Encrypts the input using your (optional) secret key and the public key of the recipient.
help Prints this message or the help of the given subcommand(s)
keygen Utility to create Crypt4GH-formatted keys.
rearrange Rearranges the input according to the edit list packet.
reencrypt Decrypts the input using your (optional) secret key and then it reencrypts it using the
public key of the recipient.
Alice and Bob generate both a pair of public/private keys.
crypt4gh keygen --sk alice.sec --pk alice.pub
crypt4gh keygen --sk bob.sec --pk bob.pub
Bob encrypts a file for Alice:
crypt4gh encrypt --sk bob.sec --recipient_pk alice.pub < file > file.c4gh
Alice decrypts the encrypted file:
crypt4gh decrypt --sk alice.sec < file.c4gh
Add this to your Cargo.toml
:
[dependencies]
crypt4gh = "0.4.0"
Use the exposed functions:
pub fn encrypt<R: Read, W: Write>(
recipient_keys: &HashSet<Keys>,
read_buffer: &mut R,
write_buffer: &mut W,
range_start: usize,
range_span: Option<usize>
) -> Result<()>
pub fn decrypt<R: Read, W: Write>(
keys: Vec<Keys>,
read_buffer: &mut R,
write_buffer: &mut W,
range_start: usize,
range_span: Option<usize>,
sender_pubkey: Option<Vec<u8>>,
) -> Result<()>
pub fn reencrypt<R: Read, W: Write>(
keys: Vec<Keys>,
recipient_keys: HashSet<Keys>,
read_buffer: &mut R,
write_buffer: &mut W,
trim: bool,
) -> Result<()>
pub fn rearrange<R: Read, W: Write>(
keys: Vec<Keys>,
read_buffer: &mut R,
write_buffer: &mut W,
range_start: usize,
range_span: Option<usize>,
) -> Result<()>
To learn more about Crypt4GH, see the official documentation.
To build from source on Windows, you should first have installed the MSVC Build Tools.