Project

xxtea-ruby

0.0
No commit activity in last 3 years
No release in over 3 years
XXTEA is a fast and secure encryption algorithm. This is a XXTEA library for Ruby. It is different from the original XXTEA encryption algorithm. It encrypts and decrypts raw binary data instead of 32bit integer array, and the key is also the raw binary data.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.9.10, ~> 1.9
 Project Readme

XXTEA for Ruby

XXTEA logo

Build Status Gem Gem Gem Gems Gems

Introduction

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

It is different from the original XXTEA encryption algorithm. It encrypts and decrypts raw binary data instead of 32bit integer array, and the key is also the raw binary data.

Installation

gem install xxtea-ruby

Usage

# encoding: utf-8
require "xxtea"
text = "Hello World! 你好,中国!"
key = "1234567890"
encrypt_data = XXTEA.encrypt(text, key)
decrypt_data = XXTEA.decrypt_utf8(encrypt_data, key)
puts (text == decrypt_data ? "success!" : "fail!");
XXTEA.decrypt_utf8(encrypt_data, key) == XXTEA.decrypt(encrypt_data, key).force_encoding(Encoding::UTF_8)

Note

decrypt_utf8 is an alias of decrypt in ruby 1.8.x or lower version.