# XTEA Cryptography Algorithm

**URL:** <https://www.ruby-forum.com/t/xtea-cryptography-algorithm/174949>\
**Category:** Ruby\
**Created:** [September 4, 2009, 3:16pm UTC](https://www.ruby-forum.com/t/xtea-cryptography-algorithm/174949 "2009-09-04T15:16:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![di3go](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@di3go](https://www.ruby-forum.com/u/di3go)\
**Post date:** [September 4, 2009, 3:16pm UTC](https://www.ruby-forum.com/t/xtea-cryptography-algorithm/174949/1 "2009-09-04T15:16:03Z")

</div>

Some one know if ruby has any implementation of XTEA algorithm?

I have a hardware connect on a serial port that uses this cryptography.

---

<div class="post-metadata">

**Author:** ![di3go](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@di3go](https://www.ruby-forum.com/u/di3go)\
**Post date:** [September 4, 2009, 3:50pm UTC](https://www.ruby-forum.com/t/xtea-cryptography-algorithm/174949/2 "2009-09-04T15:50:34Z")

</div>

-------- Original-Nachricht --------

> Datum: Fri, 4 Sep 2009 22:16:05 +0900  
> Von: Diego B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> An: removed\_email\_address@domain.invalid  
> Betreff: XTEA Cryptography Algorithm

> Some one know if ruby has any implementation of XTEA algorithm?
> 
> ## I have a hardware connect on a serial port that uses this cryptography.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Dear Diego,

you could easily adapt the C code given on the Wikipedia page.  
Ruby supports bit-level operations on numbers, and the operator symbols  
for those operations are the same as in C …  
or you could use ffi  
([http://blog.headius.com/2008/10/ffi-for-ruby-now-available.html](http://blog.headius.com/2008/10/ffi-for-ruby-now-available.html)) to use  
Ruby to wrap the C code given there right away.

Best regards,

Axel

---

<div class="post-metadata">

**Author:** ![di3go](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@di3go](https://www.ruby-forum.com/u/di3go)\
**Post date:** [September 4, 2009, 7:05pm UTC](https://www.ruby-forum.com/t/xtea-cryptography-algorithm/174949/3 "2009-09-04T19:05:33Z")

</div>

The implementation I’ve used in the past came from here -  
[http://www.jools.net/projects/ruby/crypto/](http://www.jools.net/projects/ruby/crypto/)

For some reason Firefox doesn’t like that site at the moment (claims  
it’s a  
phising site or something) - so here is a gist with the module

> <https://gist.github.com/wishdev/180989>

John

On Fri, Sep 4, 2009 at 6:16 AM, Diego B.
