gibberish 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.mdown ADDED
@@ -0,0 +1,3 @@
1
+ ### v1.1.0
2
+
3
+ Add SHA512 support
data/README.markdown CHANGED
@@ -77,6 +77,9 @@ Defaults to 128 bit digest
77
77
  Gibberish::SHA256("somedata")
78
78
  #=> 87d149cb424c0387656f211d2589fb5b1e16229921309e98588419ccca8a7362
79
79
 
80
+ Gibberish::SHA512("somedata")
81
+ #=> a053441b6de662599ecb14c580d6637dcb856a66b2a40a952d39df772e47e98ea22f9e105b31463c5cf2472feae7649464fe89d99ceb6b0bc398a6926926f416
82
+
80
83
  [Find out more](http://mdp.github.com/gibberish/Gibberish/Digest.html)
81
84
 
82
85
  ## Run the tests
@@ -6,17 +6,20 @@ module Gibberish
6
6
  # Gibberish::MD5("data") #=> 8d777f385d3dfec8815d20f7496026dc
7
7
  # Gibberish::SHA1("data") #=> a17c9aaa61e80a1bf71d0d850af4e5baa9800bbd
8
8
  # Gibberish::SHA256("data") #=> 3a6eb0790f39ac87c94f3856b2dd2c5d110e6811602261a9a923d3bb23adc8b7
9
+ # Gibberish::SHA512("data") #=> 77c7ce9a5d86bb386d443bb96390faa120633158699c8844c30b13ab0bf92760b7e4416aea397db91b4ac0e5dd56b8ef7e4b066162ab1fdc088319ce6defc876
9
10
  #
10
11
  # ## OpenSSL CLI Interop
11
12
  #
12
13
  # echo -n 'data' | openssl dgst -sha1
13
14
  # echo -n 'data' | openssl dgst -sha256
15
+ # echo -n 'data' | openssl dgst -sha512
14
16
  # echo -n 'data' | openssl dgst -md5
15
17
  #
16
18
  # is the same as
17
19
  #
18
20
  # Gibberish::SHA1("data")
19
21
  # Gibberish::SHA256("data")
22
+ # Gibberish::SHA512("data")
20
23
  # Gibberish::MD5("data")
21
24
  #
22
25
  class Digest
@@ -55,6 +58,23 @@ module Gibberish
55
58
  end
56
59
  end
57
60
 
61
+ # Returns the SHA512 digest for the data
62
+ #
63
+ # Shorcut alias: Gibberish::SHA512(data)
64
+ #
65
+ # @param [String] key
66
+ # @param [#to_s] data
67
+ # @param [Hash] options
68
+ # @option opts [Boolean] :binary (false) encode the data in binary, not Base64
69
+ def self.sha512(data, opts={})
70
+ data = data.to_s
71
+ if opts[:binary]
72
+ OpenSSL::Digest::SHA512.digest(data)
73
+ else
74
+ OpenSSL::Digest::SHA512.hexdigest(data)
75
+ end
76
+ end
77
+
58
78
  # Returns the MD5 digest for the data
59
79
  #
60
80
  # Shorcut alias: Gibberish::MD5(data)
@@ -81,6 +101,10 @@ module Gibberish
81
101
  Digest.sha256(data,opts)
82
102
  end
83
103
 
104
+ def self.SHA512(data, opts={})
105
+ Digest.sha512(data,opts)
106
+ end
107
+
84
108
  def self.MD5(data, opts={})
85
109
  Digest.md5(data,opts)
86
110
  end
@@ -1,3 +1,3 @@
1
1
  module Gibberish
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
data/spec/digest_spec.rb CHANGED
@@ -14,4 +14,8 @@ describe "A variety of digest methods" do
14
14
  Gibberish::SHA256("password").must_equal("5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8")
15
15
  end
16
16
 
17
+ it "should work with SHA512" do
18
+ Gibberish::SHA512("password").must_equal("b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86")
19
+ end
20
+
17
21
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gibberish
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease:
5
- version: 1.0.2
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 0
10
+ version: 1.1.0
6
11
  platform: ruby
7
12
  authors:
8
13
  - Mark Percival
@@ -10,7 +15,8 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-05-16 00:00:00 Z
18
+ date: 2011-11-12 00:00:00 -08:00
19
+ default_executable:
14
20
  dependencies: []
15
21
 
16
22
  description: Supports OpenSSL compatible AES, HMAC, and RSA encryption
@@ -29,6 +35,7 @@ files:
29
35
  - .yardoc/objects/root.dat
30
36
  - .yardoc/proxy_types
31
37
  - .yardopts
38
+ - CHANGELOG.mdown
32
39
  - Gemfile
33
40
  - README.markdown
34
41
  - Rakefile
@@ -48,6 +55,7 @@ files:
48
55
  - spec/openssl/public.pem
49
56
  - spec/rsa_spec.rb
50
57
  - spec/spec_helper.rb
58
+ has_rdoc: true
51
59
  homepage: http://github.com/mdp/gibberish
52
60
  licenses: []
53
61
 
@@ -61,19 +69,33 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
69
  requirements:
62
70
  - - ">="
63
71
  - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
64
75
  version: "0"
65
76
  required_rubygems_version: !ruby/object:Gem::Requirement
66
77
  none: false
67
78
  requirements:
68
79
  - - ">="
69
80
  - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
70
84
  version: "0"
71
85
  requirements: []
72
86
 
73
87
  rubyforge_project: gibberish
74
- rubygems_version: 1.7.2
88
+ rubygems_version: 1.6.2
75
89
  signing_key:
76
90
  specification_version: 3
77
91
  summary: An opinionated ruby encryption library
78
- test_files: []
79
-
92
+ test_files:
93
+ - spec/aes_spec.rb
94
+ - spec/digest_spec.rb
95
+ - spec/hmac_spec.rb
96
+ - spec/openssl/plaintext.crypted
97
+ - spec/openssl/plaintext.txt
98
+ - spec/openssl/private.pem
99
+ - spec/openssl/public.pem
100
+ - spec/rsa_spec.rb
101
+ - spec/spec_helper.rb