public
Description: Friendly tinyurl-style slugs for your activerecord and datamapper objects
Homepage:
Clone URL: git://github.com/bkerley/have-code.git
name age message
file .document Sat May 16 06:19:52 -0700 2009 Initial commit to have_code. [bkerley]
file .gitignore Loading commit data...
file LICENSE Sat May 16 06:19:52 -0700 2009 Initial commit to have_code. [bkerley]
file README.rdoc Wed Jun 10 14:33:14 -0700 2009 More details in readme [bkerley]
file Rakefile
file VERSION.yml
file have-code.gemspec
directory lib/
directory test/
README.rdoc

have-code

Add clever little base36 codes for your DataMapper and ActiveRecord objects.

Whoa seriously??

   # ActiveRecord
   class Mug < ActiveRecord::Base
     have_code 60466169, 12034710206, 81268112
   end

   initech = Mug.create :name=>'initech', :material=>'porcelain'
   code = initech.code
   initech == Mug.find_by_code code

   # DataMapper
   class Goblet
     include DataMapper::Resource
     property :id, Serial
     property :name, String
     property :material, String
     have_code 60466169, 12034710206, 81268112
   end
   kohg = Goblet.create :name=>'king of hyrule', :material=>'gold'
   code = kohg.code
   kohg == Goblet.find_by_code code

What are those big numbers?

In order:

modulus
specifies how many different plaintexts and ciphertexts are available.
a_key
multiplied against the plaintext. Must be coprime with the modulus.
b_key
added to the multiplied plaintext. No restrictions, but it’s modulus math, so making it larger than modulus is useless.

Change them to whatever you want, write tests to make sure they work as expected.

How secure is it?

Affine ciphers are incredibly easy to break. See the readme for the affine gem or en.wikipedia.org/wiki/Affine_cipher for more.

Dependencies

  • affine

Copyright

Copyright © 2009 Bryce Kerley. See LICENSE for details.