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

joe black

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

rails mysql5.0 bug

// description of your code here

   1  
   2  SET PASSWORD FOR
   3  'some_user'@'some_host' = OLD_PASSWORD('newpwd');
   4  FLUSH PRIVILEGES 

URI Parse

// description of your code here

   1  
   2  require 'net/http'
   3  res = Net::HTTP.get_response(URI.parse('http://www.example.com'))
   4  print res.body

Ruby Encrypt/Decrypt

// Quote:
technoweenie
http://www.bigbold.com/snippets/posts/show/576
hi all, I don't want repeat this snippets at all.
but, without search and under a weak tag list, hard to find what i want exactly



   1  
   2  require 'openssl'
   3  require 'digest/sha1'
   4  c = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
   5  c.encrypt
   6  # your pass is what is used to encrypt/decrypt
   7  c.key = key = Digest::SHA1.hexdigest("yourpass")
   8  c.iv = iv = c.random_iv
   9  e = c.update("crypt this")
  10  e << c.final
  11  puts "encrypted: #{e}\n"
  12  c = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
  13  c.decrypt
  14  c.key = key
  15  c.iv = iv
  16  d = c.update(e)
  17  d << c.final
  18  puts "decrypted: #{d}\n"
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS