class Anyhash
Constants
- VERSION
Public Class Methods
gost(message)
click to toggle source
# File lib/anyhash.rb, line 22 def self.gost(message) new(message).hash(Anyhash::Algorithms::GOST) end
gost_cryptopro(message)
click to toggle source
# File lib/anyhash.rb, line 26 def self.gost_cryptopro(message) new(message).hash(Anyhash::Algorithms::GOST_CRYPTOPRO) end
new(message)
click to toggle source
# File lib/anyhash.rb, line 10 def initialize(message) @message = message end
Public Instance Methods
hash(type)
click to toggle source
# File lib/anyhash.rb, line 14 def hash(type) create_tempfile write_message_to_tempfile hash = calculate_tempfile_hash_for(type) delete_tempfile hash end
Private Instance Methods
calculate_tempfile_hash_for(type)
click to toggle source
# File lib/anyhash.rb, line 41 def calculate_tempfile_hash_for(type) hash = `rhash --#{type} #{@tempfile.path}` hash.gsub(@tempfile.path, '').strip end
create_tempfile()
click to toggle source
# File lib/anyhash.rb, line 32 def create_tempfile @tempfile = Tempfile.new('message_for_rhash') end
delete_tempfile()
click to toggle source
# File lib/anyhash.rb, line 46 def delete_tempfile @tempfile.close @tempfile.unlink end
write_message_to_tempfile()
click to toggle source
# File lib/anyhash.rb, line 36 def write_message_to_tempfile @tempfile.write(@message) @tempfile.rewind end