Class: AWS::S3::Crypter
- Inherits:
-
Object
- Object
- AWS::S3::Crypter
- Defined in:
- lib/aws/s3/crypter.rb
Instance Attribute Summary collapse
-
#cipher ⇒ Object
readonly
Returns the value of attribute cipher.
Instance Method Summary collapse
- #decrypt_data(edata, key, iv) ⇒ Object
- #encrypt_data(data) ⇒ Object
-
#initialize(cipher_name = 'aes-256-cbc') ⇒ Crypter
constructor
A new instance of Crypter.
Constructor Details
#initialize(cipher_name = 'aes-256-cbc') ⇒ Crypter
Returns a new instance of Crypter.
8 9 10 |
# File 'lib/aws/s3/crypter.rb', line 8 def initialize(cipher_name = 'aes-256-cbc') @cipher = OpenSSL::Cipher::Cipher.new(cipher_name) end |
Instance Attribute Details
#cipher ⇒ Object (readonly)
Returns the value of attribute cipher.
6 7 8 |
# File 'lib/aws/s3/crypter.rb', line 6 def cipher @cipher end |
Instance Method Details
#decrypt_data(edata, key, iv) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aws/s3/crypter.rb', line 23 def decrypt_data(edata, key, iv) cipher.decrypt cipher.key = key cipher.iv = iv data = cipher.update(edata) data << cipher.final data.to_s end |
#encrypt_data(data) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/aws/s3/crypter.rb', line 12 def encrypt_data(data) cipher.encrypt key = cipher.random_key iv = cipher.random_iv edata = cipher.update(data) edata << cipher.final [edata, key, iv] end |