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
|