Skip to content

Latest commit

 

History

History
executable file
·
42 lines (34 loc) · 1.74 KB

README.md

File metadata and controls

executable file
·
42 lines (34 loc) · 1.74 KB

XXTEA for JavaScript

XXTEA logo

Build Status Gitter bower version GitHub release License

Sauce Test Status

Introduction

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

It is different from the original XXTEA encryption algorithm. It encrypts and decrypts String instead of uint32 Array, and the key is also String.

Usage

<!DOCTYPE html>
<html>
    <head>
        <title>XXTEA test</title>
        <meta charset="UTF-8">
        <script src="dist/xxtea.min.js" type="text/javascript"></script>
    </head>
    <body>
        <script type="text/javascript">
            var str = "Hello World! 你好,中国!";
            var key = "1234567890";
            var encrypt_data = XXTEA.encryptToBase64(str, key);
            console.log(encrypt_data);
            var decrypt_data = XXTEA.decryptFromBase64(encrypt_data, key);
            console.assert(str === decrypt_data);
        </script>
    </body>
</html>