Skip to content

Instantly share code, notes, and snippets.

@qmx
Last active December 25, 2015 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qmx/7018680 to your computer and use it in GitHub Desktop.
Save qmx/7018680 to your computer and use it in GitHub Desktop.
extern mod extra;
use extra::getopts::groups::*;
use std::os;
use std::libc;
#[link_args = "-lsodium"]
extern {
fn crypto_box_curve25519xsalsa20poly1305_ref_keypair(pk: *mut libc::c_char, sk: *mut libc::c_char);
}
#[fixed_stack_segment]
fn main() {
let args = os::args();
let program = args[0].clone();
let opts = ~[
optflag("h", "help", "show usage")
];
let matches = match getopts(args.tail(), opts) {
Ok(m) => { m }
Err(f) => { fail!(f.to_err_msg()) }
};
println(usage("meh", opts));
let mut pk: [libc::c_char, ..32] = [0, ..32];
let mut sk: [libc::c_char, ..32] = [0, ..32];
println(pk.to_str());
unsafe {
crypto_box_curve25519xsalsa20poly1305_ref_keypair(std::vec::raw::to_mut_ptr(pk), std::vec::raw::to_mut_ptr(sk));
}
println(pk.to_str());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment