Skip to content

Instantly share code, notes, and snippets.

@haruyama
Created August 22, 2011 05:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haruyama/1161756 to your computer and use it in GitHub Desktop.
Save haruyama/1161756 to your computer and use it in GitHub Desktop.
this creates a table of macaddress, whose prefix(vendor id) is specified, to md5
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
require 'digest/md5'
prefix =
begin
ARGV[0].downcase
rescue
'90840d'
end
def to_hex(i)
sprintf('%02x%02x%02x', i / 2**16, i / 2**8 % 2**8, i % 2**8)
end
(0...2**24).each { |i|
mac = prefix + to_hex(i)
print mac, "\t",Digest::MD5.new.update(mac),"\n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment