九月
12

1. 获取本机IP

require ‘ipaddr’
require ’socket’

$KCODE = ‘u’

p Socket.gethostbyname(’localhost’)
ip = Socket.getaddrinfo(Socket.gethostname,nil)[0][3].split(”.”)[3].to_i

p ip

2.MD5加密

require ‘digest/md5′

def getMD5(userId)

digest = Digest::MD5.hexdigest(userId)

end

puts getMD5(”caiwangqin”)

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg

Tags:

No Responses

Leave a Response

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>