Crates.io | nethsm-backup |
lib.rs | nethsm-backup |
version | |
source | src |
created_at | 2024-12-08 19:07:16.529567+00 |
updated_at | 2024-12-08 19:07:16.529567+00 |
description | A library and binary for working with encrypted NetHSM backups |
homepage | https://gitlab.archlinux.org/archlinux/signstar |
repository | https://gitlab.archlinux.org/archlinux/signstar |
max_upload_size | |
id | 1476557 |
Cargo.toml error: | TOML parse error at line 21, column 1 | 21 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A library to parse, decrypt, validate and browse NetHSM backups.
Listing all fields in a backup file:
# fn main() -> testresult::TestResult {
use std::collections::HashMap;
use nethsm_backup::Backup;
let backup = Backup::parse(std::fs::File::open("tests/nethsm.backup-file.bkp")?)?;
let decryptor = backup.decrypt(b"my-very-unsafe-backup-passphrase")?;
assert_eq!(decryptor.version()?, [0]);
for item in decryptor.items_iter() {
let (key, value) = item?;
println!("Found {key} with value: {value:X?}");
}
# Ok(()) }
Dumping the value of one specified field (here /config/version
):
# fn main() -> testresult::TestResult {
use std::collections::HashMap;
use nethsm_backup::Backup;
let backup = Backup::parse(std::fs::File::open("tests/nethsm.backup-file.bkp")?)?;
let decryptor = backup.decrypt(b"my-very-unsafe-backup-passphrase")?;
assert_eq!(decryptor.version()?, [0]);
for (key, value) in decryptor
.items_iter()
.flat_map(|item| item.ok())
.filter(|(key, _)| key == "/config/version")
{
println!("Found {key} with value: {value:X?}");
}
# Ok(()) }
Please refer to the contributing guidelines to learn how to contribute to this project.
This project may be used under the terms of the Apache-2.0 or MIT license.
Changes to this project - unless stated otherwise - automatically fall under the terms of both of the aforementioned licenses.