Class: CloudRailSi::ServiceCode::Md5

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudrail_si/servicecode/commands/hash/md5.rb

Instance Method Summary collapse

Instance Method Details

#execute(environment, parameters) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cloudrail_si/servicecode/commands/hash/md5.rb', line 11

def execute(environment, parameters)
    Helper.assert(parameters.length == 2 &&
                  Helper.is_var_address(parameters[0]))
    result_var = parameters[0]
    message = Helper.resolve(environment, parameters[1])
    Helper.assert(Helper.is_string(message))

    buf = Digest::MD5.hexdigest(message)

    number_array = []
    (0..buf.length - 1).step(2).each do |i|
        number_array.push(buf[i, 2].to_i(16))
    end

    environment.set_variable(result_var, number_array)
end

#get_identifierObject



7
8
9
# File 'lib/cloudrail_si/servicecode/commands/hash/md5.rb', line 7

def get_identifier
    'hash.md5'
end