Class: Themis::Scell
- Inherits:
-
Object
- Object
- Themis::Scell
- Includes:
- ThemisCommon, ThemisImport
- Defined in:
- lib/rbthemis.rb
Overview
Scell base class is retained for compatibility. New code should use ScellSeal, ScellTokenProtect, or ScellContextImprint.
Direct Known Subclasses
Constant Summary collapse
- SEAL_MODE =
0
- TOKEN_PROTECT_MODE =
1
- CONTEXT_IMPRINT_MODE =
2
Constants included from ThemisImport
ThemisImport::THEMIS_KEY_EC_PRIVATE, ThemisImport::THEMIS_KEY_EC_PUBLIC, ThemisImport::THEMIS_KEY_INVALID, ThemisImport::THEMIS_KEY_RSA_PRIVATE, ThemisImport::THEMIS_KEY_RSA_PUBLIC
Instance Method Summary collapse
- #decrypt(message, context = nil) ⇒ Object
- #encrypt(message, context = nil) ⇒ Object
-
#initialize(key, mode) ⇒ Scell
constructor
A new instance of Scell.
Methods included from ThemisImport
canonical_themis_paths, load_themis
Methods included from ThemisCommon
empty?, string_to_pointer_size
Constructor Details
#initialize(key, mode) ⇒ Scell
Returns a new instance of Scell.
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
# File 'lib/rbthemis.rb', line 573 def initialize(key, mode) # We could have replaced this with "self.new" but it's not possible # to override new *and* keep Scell as superclass of ScellSeal et al. # So we keep an instance of appropriate class here and never call # superclass initialize in subclasses. case mode when SEAL_MODE @cell = ScellSeal.new(key) when TOKEN_PROTECT_MODE @cell = ScellTokenProtect.new(key) when CONTEXT_IMPRINT_MODE @cell = ScellContextImprint.new(key) else raise ThemisError, "unknown Secure Cell mode: #{mode}" end warn "NOTE: #{self.class.name} is deprecated; use #{@cell.class.name} instead." end |
Instance Method Details
#decrypt(message, context = nil) ⇒ Object
595 596 597 |
# File 'lib/rbthemis.rb', line 595 def decrypt(, context = nil) @cell.decrypt(, context) end |
#encrypt(message, context = nil) ⇒ Object
591 592 593 |
# File 'lib/rbthemis.rb', line 591 def encrypt(, context = nil) @cell.encrypt(, context) end |