Permalink
Browse files

Update readme and Rakefile with new namespace

  • Loading branch information...
1 parent dc8c016 commit e37e4b212a3cf897d4ce16086f1dcc7e10da6015 @reidmorrison reidmorrison committed Apr 5, 2012
Showing with 46 additions and 15 deletions.
  1. +1 −0 .gitignore
  2. +41 −11 README.md
  3. +3 −3 Rakefile
  4. +1 −1 lib/symmetric_encryption/railtie.rb
View
1 .gitignore
@@ -3,3 +3,4 @@ nbproject/*
*.gem
.idea/*
Gemfile.lock
+._test
View
52 README.md
@@ -50,27 +50,31 @@ names with encrypted_
* More efficient replacement for attr_encrypted since only ActiveRecord Models
are extended with encrypted_ behavior, rather than every object in the system
* Custom validator for ActiveRecord Models
+* Stream based encryption and decryption so that large files can be read or
+ written with encryption
+* Stream based encryption and decryption also supports compression and decompression
+ on the fly
## Examples
### Encryption Example
- Symmetric::Encryption.encrypt "Sensitive data"
+ SymmetricEncryption.encrypt "Sensitive data"
### Decryption Example
- Symmetric::Encryption.decrypt "JqLJOi6dNjWI9kX9lSL1XQ==\n"
+ SymmetricEncryption.decrypt "JqLJOi6dNjWI9kX9lSL1XQ==\n"
### Validation Example
class MyModel < ActiveRecord::Base
- validates :encrypted_ssn, :symmetric_encrypted => true
+ validates :encrypted_ssn, :symmetric_encryption => true
end
m = MyModel.new
m.valid?
# => false
- m.encrypted_ssn = Symmetric::Encryption.encrypt('123456789')
+ m.encrypted_ssn = SymmetricEncryption.encrypt('123456789')
m.valid?
# => true
@@ -85,9 +89,9 @@ For example config/database.yml
host: db1w
database: myapp_production
username: admin
- password: <%= Symmetric::Encryption.try_decrypt "JqLJOi6dNjWI9kX9lSL1XQ==\n" %>
+ password: <%= SymmetricEncryption.try_decrypt "JqLJOi6dNjWI9kX9lSL1XQ==\n" %>
-Note: Use Symmetric::Encryption.try_decrypt method which will return nil if it
+Note: Use SymmetricEncryption.try_decrypt method which will return nil if it
fails to decrypt the value, which is essential when the encryption keys differ
between environments
@@ -100,6 +104,32 @@ Note: In order for the above technique to work in other YAML configuration files
cfg = YAML.load(ERB.new(File.new(config_file).read).result)[Rails.env]
raise("Environment #{Rails.env} not defined in redis.yml") unless cfg
+### Large File Encryption
+
+Example: Read and decrypt a line at a time from a file
+
+ SymmetricEncryption::Reader.open('encrypted_file') do |file|
+ file.each_line do |line|
+ puts line
+ end
+ end
+
+Example: Encrypt and write data to a file
+
+ SymmetricEncryption::Writer.open('encrypted_file') do |file|
+ file.write "Hello World\n"
+ file.write "Keep this secret"
+ end
+
+Example: Compress, Encrypt and write data to a file
+
+ SymmetricEncryption::Writer.open('encrypted_compressed.zip', :compress => true) do |file|
+ file.write "Hello World\n"
+ file.write "Compress this\n"
+ file.write "Keep this safe and secure\n"
+ end
+
+
### Generating encrypted passwords
The following rake task can be used to generate encrypted passwords for the
@@ -236,7 +266,7 @@ startup, run the code below to initialize symmetric-encryption prior to
attempting to encrypt or decrypt any data
require 'symmetric-encryption'
- Symmetric::Encryption.load!('config/symmetric-encryption.yml', 'production')
+ SymmetricEncryption.load!('config/symmetric-encryption.yml', 'production')
Parameters:
@@ -246,7 +276,7 @@ Parameters:
To manually generate the symmetric encryption keys, run the code below
require 'symmetric-encryption'
- Symmetric::Encryption.generate_symmetric_key_files('config/symmetric-encryption.yml', 'production')
+ SymmetricEncryption.generate_symmetric_key_files('config/symmetric-encryption.yml', 'production')
Parameters:
@@ -358,8 +388,8 @@ Create a configuration file in config/symmetric-encryption.yml per the following
Submit an issue ticket to request any of the following features:
* Ability to entirely disable encryption for a specific environment.
- Symmetric::Encryption.encrypt() would return the supplied data without encrypting it and
- Symmetric::Encryption.decrypt() would return the supplied data without decrypting it
+ SymmetricEncryption.encrypt() would return the supplied data without encrypting it and
+ SymmetricEncryption.decrypt() would return the supplied data without decrypting it
* Support for automatically compressing data prior to encrypting it when the
data exceeds some predefined size. And automatically decompressing the data
@@ -371,7 +401,7 @@ Submit an issue ticket to request any of the following features:
* Create rake task / generator to generate a sample configuration file
with a new RSA Private key already in it
-* Ability to change Symmetric::Encryption configuration options from custom
+* Ability to change SymmetricEncryption configuration options from custom
Rails initializers, rather than having everything in the config file.
For example config.symmetric_encryption.cipher = 'aes-128-cbc'
View
6 Rakefile
@@ -4,20 +4,20 @@ $:.unshift lib unless $:.include?(lib)
require 'rake/clean'
require 'rake/testtask'
require 'date'
-require 'symmetric/version'
+require 'symmetric_encryption/version'
desc "Build gem"
task :gem do |t|
gemspec = Gem::Specification.new do |s|
s.name = 'symmetric-encryption'
- s.version = Symmetric::VERSION
+ s.version = SymmetricEncryption::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ['Reid Morrison']
s.email = ['reidmo@gmail.com']
s.homepage = 'https://github.com/ClarityServices/symmetric-encryption'
s.date = Date.today.to_s
s.summary = "Symmetric Encryption for Ruby, and Ruby on Rails"
- s.description = "Symmetric Encryption is a library to seamlessly enable symmetric encryption in a project, written in Ruby."
+ s.description = "SymmetricEncryption supports encrypting ActiveRecord data, Mongoid data, passwords in configuration files, encrypting and decrypting of large files through streaming"
s.files = FileList["./**/*"].exclude('*.gem', 'nbproject').map{|f| f.sub(/^\.\//, '')}
s.has_rdoc = true
end
View
2 lib/symmetric_encryption/railtie.rb
@@ -10,7 +10,7 @@ class Railtie < Rails::Railtie #:nodoc:
# config.symmetric_encryption.cipher = 'aes-256-cbc'
# end
# end
- #config.symmetric_encryption = ::Symmetric::Config
+ #config.symmetric_encryption = ::SymmetricEncryption::Config
rake_tasks do
load "symmetric/railties/symmetric_encryption.rake"

0 comments on commit e37e4b2

Please sign in to comment.