Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 1.58 KB

README.md

File metadata and controls

36 lines (26 loc) · 1.58 KB

XXTEA for Java

XXTEA logo

Join the chat at https://gitter.im/xxtea/xxtea-java Maven Central GitHub release License

Introduction

XXTEA is a fast and secure encryption algorithm. This is a XXTEA library for Java.

It is different from the original XXTEA encryption algorithm. It encrypts and decrypts byte[] instead of 32bit integer array, and the key is also the byte[].

In addition to providing the API of byte[] encryption and decryption, it also provides some methods to handle string and Base64 encode.

Usage

package org.xxtea.test;

import org.xxtea.XXTEA;

public class Main {
    public static void main(String[] args) {
        String str = "Hello World! 你好,中国!";
        String key = "1234567890";
        byte[] encrypt_data = XXTEA.encrypt(str, key);
        String decrypt_data = XXTEA.decryptToString(encrypt_data, key);
        assert(str.equals(decrypt_data));
    }
}