Created
April 27, 2018 15:00
-
-
Save raypulver/9855d5882526e26177b700146a5139d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate openssl_sys; | |
extern crate openssl; | |
use std::mem::{ transmute }; | |
use openssl::hash::{ MessageDigest }; | |
use openssl_sys::{ EVP_MD }; | |
fn hash_something() { | |
let mut vec: Vec<u8> = (0..255).collect(); | |
let slice: &mut [u8] = vec.as_mut_slice(); | |
let digest: MessageDigest = unsafe { MessageDigest::from_ptr(transmute<[u8], *EVP_MD>(slice)); }; | |
digest.sha512(); | |
println!("{}", transmute<*EVP_MD, str>(digest.as_ptr())); | |
} | |
fn main() { | |
openssl::init(); | |
hash_something(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment