Sha256: 62b4640fe1ca1492a6d6b9ad9a93de870807df524d547b005af58a1f34ec4375

Contents?: true

Size: 579 Bytes

Versions: 22

Compression:

Stored size: 579 Bytes

Contents

require 'openssl'
module S3backup
  class Crypt
    CIPHER_ALGORITHM="aes-256-cbc"
    def initialize(password,salt)
      @password = password
      @salt = salt.scan(/../).map{|i|i.hex}.pack("c*")
    end
    def encrypt(data)
      enc = OpenSSL::Cipher::Cipher.new(CIPHER_ALGORITHM)
      enc.encrypt
      enc.pkcs5_keyivgen(@password,@salt)
      enc.update(data)+enc.final
    end
    def decrypt(data)
      enc = OpenSSL::Cipher::Cipher.new(CIPHER_ALGORITHM)
      enc.decrypt
      enc.pkcs5_keyivgen(@password,@salt)
      enc.update(data)+enc.final
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
s3backup-0.8.8 lib/s3backup/crypt.rb
s3backup-0.8.7 lib/s3backup/crypt.rb
s3backup-0.8.6 lib/s3backup/crypt.rb
s3backup-0.8.5 lib/s3backup/crypt.rb
s3backup-0.8.4 lib/s3backup/crypt.rb
s3backup-0.8.3 lib/s3backup/crypt.rb
s3backup-0.8.2 lib/s3backup/crypt.rb
s3backup-0.8.1 lib/s3backup/crypt.rb
s3backup-0.7.3 lib/s3backup/crypt.rb
s3backup-0.7.2 lib/s3backup/crypt.rb
s3backup-0.7.01 lib/s3backup/crypt.rb
s3backup-0.6.10 lib/s3backup/crypt.rb
s3backup-0.6.9 lib/s3backup/crypt.rb
s3backup-0.6.8 lib/s3backup/crypt.rb
s3backup-0.6.7 lib/s3backup/crypt.rb
s3backup-0.6.6 lib/s3backup/crypt.rb
s3backup-0.6.5 lib/s3backup/crypt.rb
s3backup-0.6.4 lib/s3backup/crypt.rb
s3backup-0.6.3 lib/s3backup/crypt.rb
s3backup-0.6.2 lib/s3backup/crypt.rb