class Tor257::Message
The message can be cut in 32 bits blocs
Public Instance Methods
decrypt(key)
click to toggle source
# File lib/tor257/core.rb, line 87 def decrypt(key) self.encrypt(key) end
encrypt(key)
click to toggle source
# File lib/tor257/core.rb, line 68 def encrypt(key) raise ArgumentError unless key.is_a? Key i = 0 rotate_matrix = [1, 2, 4, 8] out = self.bytes.map do |b| skey = key.subkey(i) STDERR.write "[#{b}]\t+ [#{skey}\t>> #{rotate_matrix}]\t-> " if $verbose skey.each_with_index do |k| b = TOR257(b, k, rotate_matrix) end STDERR.write " [#{b}]\n" if $verbose i += 1 rotate_matrix.rotate! 1 if i % 4 == 0 # bloc of 32 b.chr end.join out = Message.new(out) out end