Module: Origami::Encryption::EncryptedString
- Includes:
- EncryptedObject
- Defined in:
- lib/origami/encryption.rb
Overview
Module for encrypted String.
Instance Attribute Summary
Attributes included from EncryptedObject
Class Method Summary collapse
Instance Method Summary collapse
Methods included from EncryptedObject
Class Method Details
.extended(obj) ⇒ Object
463 464 465 |
# File 'lib/origami/encryption.rb', line 463 def self.extended(obj) obj.decrypted = false end |
Instance Method Details
#decrypt! ⇒ Object
491 492 493 494 495 496 497 498 499 500 501 502 503 |
# File 'lib/origami/encryption.rb', line 491 def decrypt! return self if @decrypted cipher = self.document.string_encryption_cipher raise EncryptionError, "Cannot find string encryption filter" if cipher.nil? key = compute_object_key(cipher) self.replace(cipher.decrypt(key, self.to_str)) @decrypted = true self end |
#encrypt! ⇒ Object
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
# File 'lib/origami/encryption.rb', line 467 def encrypt! return self unless @decrypted cipher = self.document.string_encryption_cipher raise EncryptionError, "Cannot find string encryption filter" if cipher.nil? key = compute_object_key(cipher) encrypted_data = if cipher == RC4 or cipher == Identity cipher.encrypt(key, self.value) else iv = Encryption.rand_bytes(AES::BLOCKSIZE) cipher.encrypt(key, iv, self.value) end @decrypted = false self.replace(encrypted_data) self.freeze self end |