Class: Cipher::GenericBiCipher
- Inherits:
-
SimpleCipher
- Object
- SimpleCipher
- Cipher::GenericBiCipher
- Defined in:
- lib/cipher.rb
Overview
GenericBiCipher
Generic framework class for ciphers using one cipher after another.
Instance Attribute Summary (collapse)
-
- (Object) key
readonly
Returns the value of attribute key.
-
- (Object) super_key
readonly
Returns the value of attribute super_key.
Instance Method Summary (collapse)
-
- (Object) decode(cipher)
decode.
-
- (Object) encode(plain)
encode.
-
- (GenericBiCipher) initialize(ch1, key, ch2, super_key = '')
constructor
A new instance of GenericBiCipher.
Constructor Details
- (GenericBiCipher) initialize(ch1, key, ch2, super_key = '')
Returns a new instance of GenericBiCipher
265 266 267 268 |
# File 'lib/cipher.rb', line 265 def initialize(ch1, key, ch2, super_key = '') @subst = ch1.send(:new, key) @super_key = ch2.send(:new, super_key) end |
Instance Attribute Details
- (Object) key (readonly)
Returns the value of attribute key
263 264 265 |
# File 'lib/cipher.rb', line 263 def key @key end |
- (Object) super_key (readonly)
Returns the value of attribute super_key
263 264 265 |
# File 'lib/cipher.rb', line 263 def super_key @super_key end |
Instance Method Details
- (Object) decode(cipher)
decode
278 279 280 |
# File 'lib/cipher.rb', line 278 def decode(cipher) return @subst.decode(@super_key.decode(cipher)) end |
- (Object) encode(plain)
encode
272 273 274 |
# File 'lib/cipher.rb', line 272 def encode(plain) return @super_key.encode(@subst.encode(plain)) end |