Class: CloudRailSi::ServiceCode::Sha1

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudrail_si/servicecode/commands/hash/sha1.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
27
# File 'lib/cloudrail_si/servicecode/commands/hash/sha1.rb', line 11

def execute(environment, parameters)
    Helper.assert(parameters.length == 3 &&
                  Helper.is_var_address(parameters[0]))
    result_var = parameters[0]
    key = Helper.resolve(environment, parameters[1])
    message = Helper.resolve(environment, parameters[2])
    Helper.assert(Helper.is_string(key) && Helper.is_string(message))
    hmac = HMAC::SHA1.new(key)
    hmac.update(message)
    buf = hmac.hexdigest

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

#get_identifierObject



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

def get_identifier
    'crypt.hmac.sha1'
end