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 +4 -4
- data/README.md +14 -4
- data/encrypt.gemspec +1 -1
- data/lib/encrypt.rb +2 -2
- data/lib/encrypt/version.rb +1 -1
- data/test/encrypt_test.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d684965f08f27df16f79603de53e051a1e298ef
|
4
|
+
data.tar.gz: 1812dea161842d1dba9054ca37ad70aad4fc5908
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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\"\
|
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
|
-
|
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
|
|
data/encrypt.gemspec
CHANGED
@@ -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
|
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($/)
|
data/lib/encrypt.rb
CHANGED
@@ -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(:
|
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(:
|
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
|
data/lib/encrypt/version.rb
CHANGED
data/test/encrypt_test.rb
CHANGED
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.
|
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-
|
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
|
82
|
-
|
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:
|