Skip to content

Instantly share code, notes, and snippets.

@ende76
Forked from anonymous/segfault_minimal_example.rs
Last active December 20, 2015 04: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 ende76/6068545 to your computer and use it in GitHub Desktop.
Save ende76/6068545 to your computer and use it in GitHub Desktop.
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