hashsum 2.1.5 → 2.1.6

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/hashsum +1 -1
  3. data/lib/hashsum.rb +19 -10
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a8f520079b0e1461a7b7d5fee5daf90743da2d8
4
- data.tar.gz: 4edb69a79e69fb065e99db8bbcebb87d9d1bec90
3
+ metadata.gz: ecd25b8b2e609b7bf7a394913a7de53115b006b2
4
+ data.tar.gz: 65c9806c5cf0a35f236eb9965b117f4debd10308
5
5
  SHA512:
6
- metadata.gz: fc94533e8c5dd421b79e61335634f17d1379941d5980bf72fe4268f525b777294e7ca509a5b855a1e9a9debb0ff87aed6cb5fd85e028e2c6110a1a7094f00ba5
7
- data.tar.gz: e17faa85efd90f3f87a7925ea85bbc6d0b260d58cd9c147a4b68369217b1531d99a39fcb6e30ae58ace521f38edfe61016ed2dcd806a26bb27b9dcec50f4bb30
6
+ metadata.gz: d94c5794e49665c4925efa4e60b11f379b3dd112443816fdf0b79b8bb706ea7c77ec7d7dceb78db54600c9b12e21a2405dc4fe408532ff691046e034f7a3b8ca
7
+ data.tar.gz: 444eac65605689f89ad6b2b6e1891c5a6ba447e5968af274a8f8391ad54464b9d32a1c6d84b1b4c6fce4dd3f0fb63c38677da99cc7e1df79979e36506bb7a6f4
@@ -15,7 +15,7 @@ HELP = <<-EOS
15
15
  hashsum foo -a md5
16
16
  EOS
17
17
 
18
- VERSION = '2.1.5'
18
+ VERSION = '2.1.6'
19
19
 
20
20
  case ARGV.first
21
21
  when '-h', '--help'
@@ -1,17 +1,26 @@
1
+ require 'digest'
2
+
1
3
  # @author Francesco Russo
4
+ # @version 2.1.6
2
5
  class String
3
- # Algorithms
4
- HASH = {
5
- md5: Digest::MD5,
6
- sha1: Digest::SHA1,
7
- sha2: Digest::SHA2,
8
- sha256: Digest::SHA256,
9
- sha384: Digest::SHA384,
10
- sha512: Digest::SHA512
11
- }
12
6
  # Encrypt a String with an algorithm and a salt if you want more security
13
7
  def hashsum(hash, salt = "")
14
- HASH[hash].hexdigest(salt+self)
8
+ case hash
9
+ when :md5
10
+ Digest::MD5.hexdigest(salt+self)
11
+ when :sha1
12
+ Digest::SHA1.hexdigest(salt+self)
13
+ when :sha2
14
+ Digest::SHA2.hexdigest(salt+self)
15
+ when :sha256
16
+ Digest::SHA256.hexdigest(salt+self)
17
+ when :sha384
18
+ Digest::SHA384.hexdigest(salt+self)
19
+ when :sha512
20
+ Digest::SHA512.hexdigest(salt+self)
21
+ else
22
+ self # If there isn't an hashing algorithm the method return the string
23
+ end
15
24
  end
16
25
  # Encrypt a String with MD5 and a salt if you want more security
17
26
  def to_md5(salt = "")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashsum
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Russo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-18 00:00:00.000000000 Z
11
+ date: 2013-09-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Add hashing methods to String class
14
14
  email: fraskyrusso@gmail.com