I would like to scramble all email addresses in a mysqldump file and make all the scrambled email addresses unique. Any recommendations?
Ah, SHA/MD5 for sure... But, I mean more so the script: I guess I could do a line by line gsub with Ruby?
Aaron Gibralter
2010-05-13 18:13:49
@Aaron I don't know much Ruby but that should work. You've been a bit short on details. It really matters what your end goal is and if this will become a common process that you have to do often.
Jack
2010-05-13 18:23:26
@Jack -- alright I went with this: #!/usr/bin/env ruby require 'rubygems' require 'active_support' require 'digest' $stdin.each_line do |line| s1 = ActiveSupport::SecureRandom.hex(16) s2 = ActiveSupport::SecureRandom.hex(16) puts line.gsub(/'([^\s]+?)@([^\s]+?)'/, "'#{Digest::MD5.hexdigest("#{'\1'}--#{s1}")}@#{Digest::MD5.hexdigest("#{'\2'}--#{s2}")}.com'") end
Aaron Gibralter
2010-05-13 19:14:48