Module: SwiftStorage::Utils

Includes:
Errors
Included in:
Node, Service
Defined in:
lib/swift_storage/utils.rb

Instance Method Summary collapse

Instance Method Details

#hmac(type, key, data) ⇒ Object



6
7
8
9
# File 'lib/swift_storage/utils.rb', line 6

def hmac(type, key, data)
  digest = OpenSSL::Digest.new(type)
  OpenSSL::HMAC.digest(digest, key, data)
end

#sig_to_hex(str) ⇒ Object



11
12
13
# File 'lib/swift_storage/utils.rb', line 11

def sig_to_hex(str)
  Digest.hexencode(str)
end

#struct(h) ⇒ Object



15
16
17
18
# File 'lib/swift_storage/utils.rb', line 15

def struct(h)
  return if h.empty?
  Struct.new(*h.keys.map(&:to_sym)).new(*h.values)
end