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.
- checksums.yaml +4 -4
- data/bin/hashsum +1 -1
- data/lib/hashsum.rb +19 -10
- 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: ecd25b8b2e609b7bf7a394913a7de53115b006b2
|
4
|
+
data.tar.gz: 65c9806c5cf0a35f236eb9965b117f4debd10308
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d94c5794e49665c4925efa4e60b11f379b3dd112443816fdf0b79b8bb706ea7c77ec7d7dceb78db54600c9b12e21a2405dc4fe408532ff691046e034f7a3b8ca
|
7
|
+
data.tar.gz: 444eac65605689f89ad6b2b6e1891c5a6ba447e5968af274a8f8391ad54464b9d32a1c6d84b1b4c6fce4dd3f0fb63c38677da99cc7e1df79979e36506bb7a6f4
|
data/bin/hashsum
CHANGED
data/lib/hashsum.rb
CHANGED
@@ -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
|
-
|
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.
|
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-
|
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
|