Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Matthew King

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Generate WEP hex key from plaintext

# pad the plaintext to 64 characters, then get an MD5 digest
# 128 bits, duh.

require 'digest/md5'

def pad(text)
v = text * (1 + (64 / text.length))
v[0,64]
end

def wep_key(text)
Digest::MD5.hexdigest(pad(text))
end


Environment-specific configuration in Merb

// this goes at the bottom of dist/conf/merb_init.rb

case Merb::Server.config[:environment]
when 'development'
  # do some stuff
when 'production'
  # do other stuff
end
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS