Class: Claude::Cipher
- Inherits:
-
Object
show all
- Defined in:
- lib/claude/cipher.rb
Defined Under Namespace
Classes: UnsupportedModeError
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(cipher, mode, coder = Claude.coder) ⇒ Cipher
Returns a new instance of Cipher.
28
29
30
31
32
|
# File 'lib/claude/cipher.rb', line 28
def initialize(cipher, mode, coder = Claude.coder)
@cipher = cipher
@mode = mode
@coder = coder
end
|
Class Method Details
.for_decryption(key, iv) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/claude/cipher.rb', line 20
def for_decryption(key, iv)
builder = OpenSSLCipherBuilder.new(key, iv)
mode = :decrypt
new(builder.build(mode), mode)
end
|
.for_encryption(key, iv) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/claude/cipher.rb', line 13
def for_encryption(key, iv)
builder = OpenSSLCipherBuilder.new(key, iv)
mode = :encrypt
new(builder.build(mode), mode)
end
|
Instance Method Details
#decrypt(value) ⇒ Object
38
39
40
|
# File 'lib/claude/cipher.rb', line 38
def decrypt(value)
crypt(value)
end
|
#encrypt(value) ⇒ Object
34
35
36
|
# File 'lib/claude/cipher.rb', line 34
def encrypt(value)
crypt(value)
end
|