sectok

Crates.iosectok
lib.rssectok
version0.2.0
sourcesrc
created_at2021-02-01 22:31:14.766394
updated_at2021-02-06 17:12:54.861219
descriptionA library to interact with RFC 8959 secret-token URIs
homepage
repositoryhttps://github.com/jstasiak/sectok
max_upload_size
id349425
size13,171
Jakub Stasiak (jstasiak)

documentation

README

sectok

crates.io docs.rs

A Rust library to interact with RFC 8959 secret-token URIs. Inspired by Lex Robinson's Python implementation.

See the RFC text for motivation and details.

You can find the library documentation on docs.rs.

An example of decoding a URI:

use sectok;
use std::env;

fn main() {
    match env::var("API_KEY") {
        Ok(uri) => {
            println!("The URI: {}", uri);
            match sectok::decode(&uri) {
                Some(token) => println!("The decoded token: {}", token),
                None => println!("The URI is invalid, cannot decode the token"),
            }
        }
        Err(e) => {
            println!("Cannot read environment variable: {}", e);
        }
    }
}
% API_KEY=secret-token:hello%20world cargo run --quiet --example decode
The URI: secret-token:hello%20world
The decoded token: hello world
Commit count: 13

cargo fmt