hashsum 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/hashsum +25 -20
- data/lib/hashsum.rb +0 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a8f520079b0e1461a7b7d5fee5daf90743da2d8
|
4
|
+
data.tar.gz: 4edb69a79e69fb065e99db8bbcebb87d9d1bec90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc94533e8c5dd421b79e61335634f17d1379941d5980bf72fe4268f525b777294e7ca509a5b855a1e9a9debb0ff87aed6cb5fd85e028e2c6110a1a7094f00ba5
|
7
|
+
data.tar.gz: e17faa85efd90f3f87a7925ea85bbc6d0b260d58cd9c147a4b68369217b1531d99a39fcb6e30ae58ace521f38edfe61016ed2dcd806a26bb27b9dcec50f4bb30
|
data/bin/hashsum
CHANGED
@@ -12,34 +12,39 @@ HELP = <<-EOS
|
|
12
12
|
Examples:
|
13
13
|
hashsum foo
|
14
14
|
hashsum foo bar
|
15
|
-
hashsum -a md5
|
15
|
+
hashsum foo -a md5
|
16
16
|
EOS
|
17
17
|
|
18
|
-
VERSION = '2.1.
|
18
|
+
VERSION = '2.1.5'
|
19
19
|
|
20
20
|
case ARGV.first
|
21
21
|
when '-h', '--help'
|
22
22
|
puts HELP
|
23
23
|
when '-v', '--version'
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
puts VERSION
|
25
|
+
else
|
26
|
+
*args, opt, val = ARGV
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
if opt == '-a' || opt == '--algorithm'
|
29
|
+
args.each do |arg|
|
30
|
+
puts arg.hashsum(:md5) + " " + arg if val == 'md5'
|
31
|
+
puts arg.hashsum(:sha1) + ' ' + arg if val == 'sha1'
|
32
|
+
puts arg.hashsum(:sha2) + ' ' + arg if val == 'sha2'
|
33
|
+
puts arg.hashsum(:sha256) + ' ' + arg if val == 'sha256'
|
34
|
+
puts arg.hashsum(:sha384) + ' ' + arg if val == 'sha384'
|
35
|
+
puts arg.hashsum(:sha512) + ' ' + arg if val == 'sha512'
|
36
|
+
end
|
37
|
+
else
|
38
|
+
args.each do |arg|
|
39
|
+
puts arg.hashsum(:sha1) + " " + arg
|
40
|
+
end
|
41
|
+
|
42
|
+
if opt
|
43
|
+
puts opt.hashsum(:sha1) + " " + opt
|
44
|
+
else
|
45
|
+
puts "\e[31mERROR\e[0m: Invalid option. See 'hashsum -h'"
|
46
|
+
end
|
30
47
|
|
31
|
-
|
32
|
-
puts arg.hashsum(:md5) + ' ' + arg if algorithm == 'md5'
|
33
|
-
puts arg.hashsum(:sha1) + ' ' + arg if algorithm == 'sha1'
|
34
|
-
puts arg.hashsum(:sha2) + ' ' + arg if algorithm == 'sha2'
|
35
|
-
puts arg.hashsum(:sha256) + ' ' + arg if algorithm == 'sha256'
|
36
|
-
puts arg.hashsum(:sha384) + ' ' + arg if algorithm == 'sha384'
|
37
|
-
puts arg.hashsum(:sha512) + ' ' + arg if algorithm == 'sha512'
|
38
|
-
end
|
39
|
-
when nil
|
40
|
-
puts "\e[31mERROR\e[0m: Invalid option. See 'hashsum -h'"
|
41
|
-
else
|
42
|
-
ARGV.each do |arg|
|
43
|
-
puts arg.hashsum(:sha1) + ' ' + arg
|
48
|
+
puts val.hashsum(:sha1) + " " + val if val
|
44
49
|
end
|
45
50
|
end
|
data/lib/hashsum.rb
CHANGED
@@ -10,37 +10,30 @@ class String
|
|
10
10
|
sha512: Digest::SHA512
|
11
11
|
}
|
12
12
|
# Encrypt a String with an algorithm and a salt if you want more security
|
13
|
-
# hashsum(hash, salt = "")
|
14
13
|
def hashsum(hash, salt = "")
|
15
14
|
HASH[hash].hexdigest(salt+self)
|
16
15
|
end
|
17
16
|
# Encrypt a String with MD5 and a salt if you want more security
|
18
|
-
# to_md5(salt = "")
|
19
17
|
def to_md5(salt = "")
|
20
18
|
hashsum(:md5, salt)
|
21
19
|
end
|
22
20
|
# Encrypt a String with SHA1 and a salt if you want more security
|
23
|
-
# to_sha1(salt = "")
|
24
21
|
def to_sha1(salt = "")
|
25
22
|
hashsum(:sha1, salt)
|
26
23
|
end
|
27
24
|
# Encrypt a String with SHA2 and a salt if you want more security
|
28
|
-
# to_sha2(salt = "")
|
29
25
|
def to_sha2(salt = "")
|
30
26
|
hashsum(:sha2, salt)
|
31
27
|
end
|
32
28
|
# Encrypt a String with SHA256 and a salt if you want more security
|
33
|
-
# to_sha256(salt = "")
|
34
29
|
def to_sha256(salt = "")
|
35
30
|
hashsum(:sha256, salt)
|
36
31
|
end
|
37
32
|
# Encrypt a String with SHA384 and a salt if you want more security
|
38
|
-
# to_384(salt = "")
|
39
33
|
def to_sha384(salt = "")
|
40
34
|
hashsum(:sha384, salt)
|
41
35
|
end
|
42
36
|
# Encrypt a String with SHA512 and a salt if you want more security
|
43
|
-
# to_sha512(salt = "")
|
44
37
|
def to_sha512(salt = "")
|
45
38
|
hashsum(:sha512, salt)
|
46
39
|
end
|
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.
|
4
|
+
version: 2.1.5
|
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-
|
11
|
+
date: 2013-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Add hashing methods to String class
|
14
14
|
email: fraskyrusso@gmail.com
|