Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- #
- # Hash format: username::domain:1122334455667788:3B5889EBD28E72A95084162766094D23:010100000000000
- #
- hashes = File.open(ARGV[0]).read
- new_hashes = {}
- hashes.split("\n").each do |hash|
- username = hash.match(/^.+::/)[0].gsub('::','')
- parts = hash.gsub(username+'::', '').split(':')
- new_hashes[username] = { :part0 => parts[0], :part1 => parts[1], :part2 => parts[2], :part3 => parts[3] }
- end
- new_hashes.each_pair do |key, value|
- part0 = value[:part0].nil? ? '' : value[:part0]
- part1 = value[:part1].nil? ? '' : value[:part1]
- part2 = value[:part2].nil? ? '' : value[:part2]
- part3 = value[:part3].nil? ? '' : value[:part3]
- if part3 == ''
- puts key + '::' + part0 + ':' + part1 + ':' + part2
- else
- puts key + '::' + part0 + ':' + part1 + ':' + part2 + ':' + part3
- end
- end
- exit
Advertisement
Add Comment
Please, Sign In to add comment