Class: Cipher::Wheatstone
- Inherits:
-
Substitution
show all
- Includes:
- Crypto
- Defined in:
- lib/cipher.rb
Overview
Constant Summary
Constant Summary
Constants included
from Crypto
Crypto::BASE
Instance Attribute Summary
Attributes inherited from Substitution
#key
Instance Method Summary
(collapse)
Methods included from Crypto
#addmod10, #chainadd, #expand5to10, #find_hole, #keyshuffle, #normalize, #p1_encode, #str_to_numeric, #submod10
#decode
#decode
Constructor Details
- (Wheatstone) initialize(start, plain, cipher)
334
335
336
|
# File 'lib/cipher.rb', line 334
def initialize(start, plain, cipher)
@key = Key::Wheatstone.new(start, plain, cipher)
end
|
Instance Method Details
- (Object) encode(plain_text)
340
341
342
343
344
345
346
347
348
349
|
# File 'lib/cipher.rb', line 340
def encode(plain_text)
pl = plain_text.replace_double('Q')
cipher_text = pl.each_char.inject('') do |text, pt|
text + @key.encode(pt)
end
cipher_text
end
|