Advertisement
devwild

patternShift.rb

Dec 10th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.37 KB | None | 0 0
  1. hex = IO.binread("hex.txt").scan(/[0-9a-fA-Z]{2}/).map { |n| n.to_i(16) }
  2. pattern = IO.binread("pattern.txt").split(",").map { |n| n.to_i }
  3. IO.binwrite("output_added.txt",hex.length.times.map { |n| ((hex[n].ord + pattern[n % pattern.size]) % 256).chr }.join)
  4. IO.binwrite("output_subbed.txt",hex.length.times.map { |n| ((hex[n].ord - pattern[n % pattern.size]) % 256).chr }.join
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement