New AES gem available -- fast-aes

Discussion in 'Ruby' started by Nate Wiger, Jan 20, 2010.

  1. Nate Wiger

    Nate Wiger Guest

    I've just released a new AES gem for Ruby, written in C for speed.
    This gem leverages some open source AES C code that has been in use
    for many years. I created this gem because other AES implementations
    didn't even run, or were buggy, or performed poorly, or all of the
    above.

    To install:

    gem install fast-aes

    Usage is very easy and docs are available here:

    http://github.com/nateware/fast-aes

    Enjoy,

    Nate Wiger
     
    Nate Wiger, Jan 20, 2010
    #1
    1. Advertising

  2. Nate Wiger wrote:
    > I've just released a new AES gem for Ruby, written in C for speed.
    > This gem leverages some open source AES C code that has been in use


    Great. Hopefully what I've been looking for.

    I've been using Encryptor.encrypt:)value => string , :key => key,
    :algorithm => 'aes-128-cbc') in a module created on my own. Is your gem
    faster?

    I should add that I don't fully understand this thing with encryption
    and the terminology. Could you explain a bit the key length and 128 bit?
    Is it always the length as in your example?


    --
    Posted via http://www.ruby-forum.com/.
     
    Pål Bergström, Jul 1, 2010
    #2
    1. Advertising

  3. Nate Wiger

    Josh Cheek Guest

    2010/7/1 P=E5l Bergstr=F6m <>

    > I should add that I don't fully understand this thing with encryption
    > and the terminology. Could you explain a bit the key length and 128 bit?
    > Is it always the length as in your example?
    >
    >

    Empirically yes:

    require 'rubygems'
    require 'fast-aes'
    require 'pp'

    key , results =3D String.new , Array.new

    for char in [*'a'..'z'] + [*'A'..'H']
    results << begin
    FastAES.new key and "Valid: #{key}"
    rescue =3D> error
    error
    end
    key << char
    end

    pp results




    Definitively (fast_aes.c), still yes:

    key_bits =3D strlen(key_data)*8;
    switch(key_bits)
    {
    case 128:
    case 192:
    case 256:
    fast_aes->key_bits =3D key_bits;
    memcpy(fast_aes->key, key_data, key_bits/8);
    /*printf("AES key=3D%s, bits=3D%d\n", fast_aes->key,
    fast_aes->key_bits);*/
    break;
    default:
    sprintf(error_mesg, "AES key must be 128, 192, or 256 bits in lengt=
    h
    (got %d): %s", key_bits, key_data);
    rb_raise(rb_eArgError, error_mesg);
    return Qnil;
    }
     
    Josh Cheek, Jul 1, 2010
    #3
  4. Josh Cheek wrote:


    > Definitively (fast_aes.c), still yes:


    And for saving it in mysql, how do I translate it from binary (?)
    "garbage" characters (is that how you explain it) to a string? I use
    Base64.b64encode(fast_aes_string) now. Is there a faster way?

    --
    Posted via http://www.ruby-forum.com/.
     
    Pål Bergström, Jul 1, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    701
  2. Michele Simionato

    Python is darn fast (was: How fast is Python)

    Michele Simionato, Aug 23, 2003, in forum: Python
    Replies:
    13
    Views:
    590
  3. Juha Nieminen
    Replies:
    22
    Views:
    1,072
    Kai-Uwe Bux
    Oct 12, 2007
  4. Austin 7873
    Replies:
    5
    Views:
    216
    Eric Hodel
    Jan 27, 2007
  5. explainer

    New gem available: rmb-rails

    explainer, Jul 27, 2009, in forum: Ruby
    Replies:
    0
    Views:
    97
    explainer
    Jul 27, 2009
Loading...

Share This Page