Skip to content
This repository was archived by the owner on Jan 9, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aescrypt.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
gem.files = `git ls-files`.split("\n")
gem.name = "aescrypt"
gem.require_paths = ["lib"]
gem.version = "1.0.1"
gem.version = "1.0.2"

gem.add_development_dependency "rake"
end
10 changes: 5 additions & 5 deletions lib/aescrypt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@

module AESCrypt
def self.encrypt(message, password)
Base64.encode64(self.encrypt_data(message.to_s.strip, self.key_digest(password), nil, "AES-256-CBC"))
::Base64.encode64(self.encrypt_data(message.to_s.strip, self.key_digest(password), nil, "AES-256-CBC"))
end

def self.decrypt(message, password)
base64_decoded = Base64.decode64(message.to_s.strip)
base64_decoded = ::Base64.decode64(message.to_s.strip)
self.decrypt_data(base64_decoded, self.key_digest(password), nil, "AES-256-CBC")
end

def self.key_digest(password)
OpenSSL::Digest::SHA256.new(password).digest
::OpenSSL::Digest::SHA256.new(password).digest
end

# Decrypts a block of data (encrypted_data) given an encryption key
Expand All @@ -55,7 +55,7 @@ def self.key_digest(password)
#:arg: iv => String
#:arg: cipher_type => String
def self.decrypt_data(encrypted_data, key, iv, cipher_type)
aes = OpenSSL::Cipher::Cipher.new(cipher_type)
aes = ::OpenSSL::Cipher::Cipher.new(cipher_type)
aes.decrypt
aes.key = key
aes.iv = iv if iv != nil
Expand All @@ -74,7 +74,7 @@ def self.decrypt_data(encrypted_data, key, iv, cipher_type)
#:arg: iv => String
#:arg: cipher_type => String
def self.encrypt_data(data, key, iv, cipher_type)
aes = OpenSSL::Cipher::Cipher.new(cipher_type)
aes = ::OpenSSL::Cipher::Cipher.new(cipher_type)
aes.encrypt
aes.key = key
aes.iv = iv if iv != nil
Expand Down