cf_crypto 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cf_crypto.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Ryan Ricard
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # CfCrypto
2
+
3
+ A gem that helps Ruby applications exchange encrypted data with ColdFusion.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cf_crypto'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cf_crypto
18
+
19
+ ## Usage
20
+
21
+ ### AES: the Advanced Encryption Standard specified by the National Institute of Standards and Technology (NIST) FIPS-197.
22
+
23
+ Not yet supported.
24
+
25
+ ### BLOWFISH: the Blowfish algorithm defined by Bruce Schneier.
26
+
27
+ Not yet supported.
28
+
29
+ ### DES: the Data Encryption Standard algorithm defined by NIST FIPS-46-3.
30
+
31
+ **CfCrypto::DES.encrypt(string, key)**
32
+
33
+ * string (required): a string to be encrypted
34
+ * key (required): key to be used by DES for encryption
35
+
36
+ **CfCrypto::DES.decrypt(string, key)**
37
+
38
+ * string (required): a string to be decrypted
39
+ * key (required): key to be used by DES for decryption
40
+
41
+ ### DESEDE: the "Triple DES" algorithm defined by NIST FIPS-46-3.
42
+
43
+ Not yet supported.
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/cf_crypto.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/cf_crypto/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Ryan Ricard"]
6
+ gem.email = ["ryan.ricard@gmail.com"]
7
+ gem.description = "A gem that helps Ruby applications exchange encrypted data with ColdFusion."
8
+ gem.summary = "A gem that helps Ruby applications exchange encrypted data with ColdFusion."
9
+ gem.homepage = "https://github.com/ryanricard/cf_crypto"
10
+
11
+ gem.add_development_dependency "rspec"
12
+
13
+ gem.files = `git ls-files`.split($\)
14
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.name = "cf_crypto"
17
+ gem.require_paths = ["lib"]
18
+ gem.version = CfCrypto::VERSION
19
+ end
@@ -0,0 +1,3 @@
1
+ module CfCrypto
2
+ VERSION = "0.0.1"
3
+ end
data/lib/cf_crypto.rb ADDED
@@ -0,0 +1,39 @@
1
+ require "cf_crypto/version"
2
+
3
+ module CfCrypto
4
+
5
+ require "OpenSSL"
6
+ require "Base64"
7
+
8
+ #DES decryption module
9
+ module DES
10
+
11
+ def self.decrypt(string, key)
12
+ decipher = OpenSSL::Cipher::Cipher.new('des-ecb')
13
+ decipher.decrypt
14
+ decipher.key = Base64.decode64(key.strip)
15
+ data = hex_to_data(string)
16
+ data = decipher.update(data) + decipher.final()
17
+ end
18
+
19
+ def self.encrypt(string, key)
20
+ decipher = OpenSSL::Cipher::Cipher.new('des-ecb')
21
+ decipher.encrypt
22
+ decipher.key = Base64.decode64(key.strip)
23
+ data = decipher.update(string) + decipher.final()
24
+ data_to_hex(data)
25
+ end
26
+
27
+ private
28
+
29
+ def self.data_to_hex(string)
30
+ string.strip.unpack('H*')[0]
31
+ end
32
+
33
+ def self.hex_to_data(hex)
34
+ Array(hex.strip).pack('H*')
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe "CfCrypto" do
4
+
5
+ let(:sensitive_information){ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." }
6
+
7
+ describe "DES" do
8
+
9
+ let(:des_key){ "sAd!DF%lX^ka&Gs*jHd" }
10
+
11
+ it "should encrypt and decrypt a string" do
12
+ result = CfCrypto::DES.encrypt(sensitive_information, des_key)
13
+ result.should_not eq(sensitive_information)
14
+ result = CfCrypto::DES.decrypt(result, des_key)
15
+ result.should eq(sensitive_information)
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,13 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper.rb"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'cf_crypto'
8
+
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cf_crypto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Ricard
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &2152567020 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2152567020
25
+ description: A gem that helps Ruby applications exchange encrypted data with ColdFusion.
26
+ email:
27
+ - ryan.ricard@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - .rspec
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - cf_crypto.gemspec
39
+ - lib/cf_crypto.rb
40
+ - lib/cf_crypto/version.rb
41
+ - spec/cf_crypto_spec.rb
42
+ - spec/spec_helper.rb
43
+ homepage: https://github.com/ryanricard/cf_crypto
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.17
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: A gem that helps Ruby applications exchange encrypted data with ColdFusion.
67
+ test_files:
68
+ - spec/cf_crypto_spec.rb
69
+ - spec/spec_helper.rb