encrypt 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ec8280c8a6ae60580cd5283a0156bbced5d56b7
4
- data.tar.gz: e774ff6e6838bff3bd49e228aeb14adc21f594ea
3
+ metadata.gz: 0d684965f08f27df16f79603de53e051a1e298ef
4
+ data.tar.gz: 1812dea161842d1dba9054ca37ad70aad4fc5908
5
5
  SHA512:
6
- metadata.gz: f08646430895d8ce7f4f7a3690c456b83f3e3f2ee49155d7a1922713a12d71bfddd7aebcb8b945946be8da2dbc2d4981f52bdd3041d91f7bbdc3147a9cdea382
7
- data.tar.gz: 30a5dee8f3f1239ce0bf604604c1849dfd0fe0a5fbb8712cc8047dbc48482c9902c47a54ebcdb03dc2045ba26e10797dfeb36bd4fa2bbffa74be58ed5aaec842
6
+ metadata.gz: 365b36944af7fbde9e44aec92f5ea14785ecbde4d33c550bae78512a3196ff0c53bb3cb2bd0ba41e1bb7db0ac8d2b34c4db98a55698e0ef7855d9a7477163e84
7
+ data.tar.gz: 45a6893dc869fe0ef1f0980ff220fee735539c336e9534fab705f250c16715ea0faaedf434a84e16dc7327ab8a3dc0196b4e67b005ac54903b4fd283dcf671d0
data/README.md CHANGED
@@ -2,22 +2,28 @@
2
2
 
3
3
  A gem for encrypting and decrypting strings with AES-256. Just supply the password.
4
4
 
5
- Encrypt uses an AES-256 cipher in CTR mode. A randomly generated salt and IV are publicly stored along with the encrypted data.
5
+ Encrypt uses an AES-256 cipher in CBC mode. A randomly generated salt and IV are publicly stored along with the encrypted data.
6
6
 
7
- Encrypt makes use of Ruby 2.0's experimental refinements to extend String locally, adding the #encrypt and #decrypt methods. Activate the refinement with using: `using Encrypt`.
7
+ Encrypt makes use of refinements to extend String locally, adding the #encrypt and #decrypt methods. Activate the refinement with `using Encrypt`.
8
8
 
9
9
  ## Usage
10
10
 
11
11
  ```ruby
12
12
  require 'encrypt'
13
13
 
14
+ 'not yet'.encrypt 'refinement not activated'
15
+ #=> NoMethodError: undefined method `encrypt' for "not yet":String
16
+
14
17
  using Encrypt
15
18
 
16
19
  encrypted = 'super sekret'.encrypt 'passw0rd'
17
- #=> "\x04\b[\b\"\x15H\xEB\x8C\xE6\xA2r\xDA\x15\xDDH\xEB\xF2|\x11\xEFF\"\x15\xE9\xBB\xB1\xCEO\xB6Y\x19zk\xDD\xD5\x9A\xBD\x01\xF5\"\x11F/1\x1D;2g\xFC\xB8np\xBC"
20
+ #=> "\x04\b[\b\"\x15\x9FK\x18+\xA3X\x96S\xD9\xF2L. \x15\a2\"\x15,x)\xE2\xDA~\xA0\x90M\x06\xB0\xAC&\x89\xEFw\"\x15n\x90\xDCq2\x9B\xA8\x80Ca\xBB\x0F+NT\xD4"
18
21
 
19
22
  encrypted.decrypt 'passw0rd'
20
23
  #=> "super sekret"
24
+
25
+ encrypted.decrypt 'wrong'
26
+ #=> OpenSSL::Cipher::CipherError: bad decrypt
21
27
  ```
22
28
 
23
29
  ## Installation
@@ -29,7 +35,11 @@ encrypted.decrypt 'passw0rd'
29
35
  Ruby 2.0.0+ (uses [experimental refinements](http://www.ruby-doc.org/core-2.0/doc/syntax/refinements_rdoc.html))
30
36
 
31
37
  ## Alternatives
32
- The [RbNACL](https://github.com/cryptosphere/rbnacl#readme) gem has been more thoroughly vetted and is a recommended alternative.
38
+
39
+ Want a cipher other than AES-256 or a mode other than CBC? A project that has been more thoroughly vetted? Looking for something that works on Ruby 1.9? Here are some alternatives:
40
+ * [Krypt](https://github.com/krypt/krypt#readme)
41
+ * [RbNACL](https://github.com/cryptosphere/rbnacl#readme)
42
+ * [libsodium](https://github.com/jedisct1/libsodium#readme)
33
43
 
34
44
  ## Contributing
35
45
 
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.authors = ['Shannon Skipper']
8
8
  spec.email = ['shannonskipper@gmail.com']
9
9
  spec.description = %q{A gem for encrypting and decrypting strings with AES-256. Just supply the password.}
10
- spec.summary = %q{Encrypt and decrypt strings with AES-256 in CTR mode. Encrypt uses Ruby 2.0's experimental refinements to extend String locally to add the #encrypt and #decrypt methods.}
10
+ spec.summary = %q{Encrypt and decrypt strings with AES-256 in CBC mode. Encrypt uses Ruby refinements to extend String locally to add the #encrypt and #decrypt methods.}
11
11
  spec.homepage = 'https://github.com/havenwood/encrypt#readme'
12
12
  spec.license = 'MIT'
13
13
  spec.files = `git ls-files`.split($/)
@@ -3,7 +3,7 @@ require 'openssl'
3
3
  module Encrypt
4
4
  refine String do
5
5
  def encrypt key
6
- cipher = OpenSSL::Cipher::AES256.new(:CTR)
6
+ cipher = OpenSSL::Cipher::AES256.new(:CBC)
7
7
  cipher.encrypt
8
8
  salt = OpenSSL::Random.random_bytes(16)
9
9
  cipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(key, salt, 20000, 32)
@@ -13,7 +13,7 @@ module Encrypt
13
13
 
14
14
  def decrypt key
15
15
  salt, iv, encrypted = Marshal.load(self)
16
- cipher = OpenSSL::Cipher::AES256.new(:CTR)
16
+ cipher = OpenSSL::Cipher::AES256.new(:CBC)
17
17
  cipher.decrypt
18
18
  cipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(key, salt, 20000, 32)
19
19
  cipher.iv = iv
@@ -1,3 +1,3 @@
1
1
  module Encrypt
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -14,7 +14,7 @@ describe Encrypt do
14
14
  end
15
15
 
16
16
  it 'does not decrypt with incorrect key' do
17
- refute_equal 'sekret', @encrypted.decrypt('password')
17
+ assert_raises(OpenSSL::Cipher::CipherError) { @encrypted.decrypt('pwd') }
18
18
  end
19
19
 
20
20
  it 'decrypts' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: encrypt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shannon Skipper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-19 00:00:00.000000000 Z
11
+ date: 2013-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,9 +78,8 @@ rubyforge_project:
78
78
  rubygems_version: 2.0.5
79
79
  signing_key:
80
80
  specification_version: 4
81
- summary: 'Encrypt and decrypt strings with AES-256 in CTR mode. Encrypt uses Ruby
82
- 2.0''s experimental refinements to extend String locally to add the #encrypt and
83
- #decrypt methods.'
81
+ summary: 'Encrypt and decrypt strings with AES-256 in CBC mode. Encrypt uses Ruby
82
+ refinements to extend String locally to add the #encrypt and #decrypt methods.'
84
83
  test_files:
85
84
  - test/encrypt_test.rb
86
85
  has_rdoc: