Forked from anonymous/segfault_minimal_example.rs
Last active
December 20, 2015 04:09
-
-
Save ende76/6068545 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
use std::vec; | |
fn encrypt_decrypt_consistent_key() -> (@fn(&[u8]) -> ~[u8], @fn(&[u8]) -> ~[u8]) { | |
let key = "random key".as_bytes().to_owned(); | |
let key0 = copy key; | |
(|bytes: &[u8]| { | |
vec::append(bytes.to_owned(), key) | |
}, |bytes: &[u8]| { | |
vec::append(bytes.to_owned(), key) | |
}) | |
} | |
fn main() { | |
let (encrypt, decrypt) = encrypt_decrypt_consistent_key(); | |
let plaintext_bytes = "plaintext".as_bytes(); | |
let encrypted_bytes = encrypt(plaintext_bytes); | |
let decrypted_bytes = decrypt(encrypted_bytes); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment