Class: S7n::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/s7n/key.rb

Overview

暗号化用のキーを表現する。

Direct Known Subclasses

Md5Key, Sha1Key

Constant Summary collapse

@@key_classes =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(passphrase) ⇒ Key

Returns a new instance of Key.



29
30
31
32
# File 'lib/s7n/key.rb', line 29

def initialize(passphrase)
  @key = OpenSSL::Digest.digest(hash_type, passphrase)
  @length = @key.length
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



26
27
28
# File 'lib/s7n/key.rb', line 26

def key
  @key
end

#lengthObject (readonly)

Returns the value of attribute length.



27
28
29
# File 'lib/s7n/key.rb', line 27

def length
  @length
end

Class Method Details

.create_instance(type, passphrase) ⇒ Object



11
12
13
# File 'lib/s7n/key.rb', line 11

def create_instance(type, passphrase)
  return @@key_classes[type].new(passphrase)
end