tags:

views:

24

answers:

1

I would like to scramble all email addresses in a mysqldump file and make all the scrambled email addresses unique. Any recommendations?

A: 

base64 if you want to be able to "unscramble" and sha1 or md5 if not.

Jack
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
@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
@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