Class: Crypt::BlockTEA

Inherits:
Object
  • Object
show all
Defined in:
lib/crypt/block_tea.rb

Constant Summary collapse

DELTA =
0x9E3779B9

Instance Method Summary collapse

Constructor Details

#initialize(password) ⇒ BlockTEA

Returns a new instance of BlockTEA.



5
6
7
# File 'lib/crypt/block_tea.rb', line 5

def initialize(password)
  @password = password
end

Instance Method Details

#decrypt(ciphertext) ⇒ Object

Raises:

  • (StandardError)


16
17
18
19
# File 'lib/crypt/block_tea.rb', line 16

def decrypt(ciphertext)
  raise StandardError, "Nothing to decrypt" if ciphertext.length == 0
  decryption_algorithm(ciphertext)
end

#encrypt(plaintext) ⇒ Object

Raises:

  • (StandardError)


10
11
12
13
# File 'lib/crypt/block_tea.rb', line 10

def encrypt(plaintext)
  raise StandardError, "Nothing to encrypt" if plaintext.length == 0
  encryption_algorithm(plaintext)
end