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
388 389 390 |
# File 'lib/origami/encryption.rb', line 388 def self.extended(obj) obj.decrypted = false end |
Instance Method Details
#decrypt! ⇒ Object
416 417 418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/origami/encryption.rb', line 416 def decrypt! return self if @decrypted cipher = document.string_encryption_cipher raise EncryptionError, "Cannot find string encryption filter" if cipher.nil? key = compute_object_key(cipher) replace(cipher.decrypt(key, to_str)) @decrypted = true self end |
#encrypt! ⇒ Object
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
# File 'lib/origami/encryption.rb', line 392 def encrypt! return self unless @decrypted cipher = document.string_encryption_cipher raise EncryptionError, "Cannot find string encryption filter" if cipher.nil? key = compute_object_key(cipher) encrypted_data = if (cipher == RC4) || (cipher == Identity) cipher.encrypt(key, value) else iv = Encryption.rand_bytes(AES::BLOCKSIZE) cipher.encrypt(key, iv, value) end @decrypted = false replace(encrypted_data) freeze self end |