3 unstable releases

Uses old Rust 2015

0.2.0 Dec 5, 2017
0.1.1 Apr 9, 2017
0.1.0 Mar 13, 2017

#1489 in Algorithms

MIT license

7KB
119 lines

XXTEA-Rust

Build Status
XXTEA encryption algorithm library

What is XXTEA

see this page

Example

extern crate xxtea;
extern crate base64;

use base64::{encode, decode};
use std::str;

fn main() {
    let data = "Hello World";
    let key = "This is the key";

    // encrypt
    let result: String = encode(xxtea::encrypt(&data, &key).as_slice());
    println!("{}", result); // will output GEvbeEorvUJmCT2A2j5bGw==

    // decrypt
    let plain_bytes: Vec<u8> = xxtea::decrypt(&decode(&result).unwrap(), &key);

    let plain_texts = match str::from_utf8(plain_bytes.as_slice()) {
        Ok(v) => v,
        Err(e) => panic!("Invalid UTF-8 sequence: {}", e),
    };
    println!("{}", plain_texts);  // will output Hello World
}

Contributor

Daniel

LICENSE

MIT

No runtime deps