Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Hanaasagi/XXTEA-Rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages