11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/diversion/decode/json.rb', line 11
def get_hash(data, options)
arr = data.split('-')
raise Error::BadUrlDataFormat unless arr.length.between?(1,2)
json_raw = Url::decode_url(arr.first)
begin
hash = MultiJson.load(json_raw)
rescue
return {:parsed => false}
end
hash = HashWithIndifferentAccess.new.merge(hash)
hash[:parsed] = true
if arr.length == 2
hash[:signed] = true
hash[:key_presented] = arr[1]
hash[:key_expected] = Signing::sign_data(options[:sign_key], options[:sign_length], json_raw)
hash[:key_verified] = hash[:key_presented] == hash[:key_expected]
else
hash[:signed] = false
hash[:key_presented] = ""
hash[:key_expected] = ""
hash[:key_verified] = false
end
hash.symbolize_keys
end
|