webget_ruby_password_hash 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig ADDED
Binary file
@@ -0,0 +1,52 @@
1
+ =begin rdoc
2
+
3
+ = WebGet Ruby Gem: Password Hash to do secure SHA256 passwords.
4
+
5
+ Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
6
+ Copyright:: Copyright (c) 2006-2010 Joel Parker Henderson
7
+ License:: CreativeCommons License, Non-commercial Share Alike
8
+ License:: LGPL, GNU Lesser General Public License
9
+
10
+ Password hash tool to create secure passwords,
11
+
12
+ This uses SHA256 hexdigest for the cryptographic hash,
13
+ and authenticates a password, salt, and hash.
14
+
15
+ To create a password:
16
+ require 'webget_ruby_password_hash'
17
+ text = 'mysecret'
18
+ salt = 'azsxdcfv'
19
+ hash = PasswordHash.new(text,salt)
20
+
21
+ To create a password using our helpers:
22
+ require 'webget_ruby_password_hash'
23
+ require 'webget_ruby_password_salt'
24
+ require 'webget_ruby_password_text'
25
+ text = PasswordText.new
26
+ salt = PasswordSalt.new
27
+ hash = PasswordHash.new(text,salt)
28
+
29
+ To verify a password:
30
+ hash.valid?(text,salt)
31
+
32
+ To verify a password from a web form for a user:
33
+ user = User.find(params[:id]) or raise 'user not found'
34
+ user.hash.valid?(params[:password],user.salt)
35
+
36
+ =end
37
+
38
+ require 'digest/sha2'
39
+
40
+ class PasswordHash < String
41
+
42
+ def initialize(text,salt)
43
+ text or raise "text:#{text}"
44
+ salt or raise "salt:#{salt}"
45
+ super(Digest::SHA256.hexdigest(text+salt))
46
+ end
47
+
48
+ def valid?(text,salt)
49
+ self == Digest::SHA256.hexdigest(text+salt)
50
+ end
51
+
52
+ end
@@ -0,0 +1,24 @@
1
+ require 'test/unit'
2
+ require 'webget_ruby_password_hash'
3
+
4
+ class Testing < Test::Unit::TestCase
5
+
6
+ def test_new
7
+ p = PasswordHash.new('foo','bar')
8
+ assert_not_nil(p,"p")
9
+ assert(p.is_a?(String),"p is a string")
10
+ end
11
+
12
+ def test_valid
13
+ p = PasswordHash.new('foo','bar')
14
+ assert(p.valid?('foo','bar'), "p.valid? foo bar")
15
+ end
16
+
17
+ def test_invalid
18
+ p = PasswordHash.new('foo','bar')
19
+ assert(!p.valid?('foo','xxx'), "p.valid? foo xxx")
20
+ assert(!p.valid?('xxx','bar'), "p.valid? xxx bar")
21
+ end
22
+
23
+ end
24
+
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webget_ruby_password_hash
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - WebGet
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDvDCCAyWgAwIBAgIJAIlSqEkDQaZIMA0GCSqGSIb3DQEBBQUAMIGbMQswCQYD
14
+ VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5j
15
+ aXNjbzETMBEGA1UEChMKV2ViR2V0LmNvbTETMBEGA1UECxMKV2ViR2V0LmNvbTET
16
+ MBEGA1UEAxMKV2ViR2V0LmNvbTEgMB4GCSqGSIb3DQEJARYRd2ViZ2V0QHdlYmdl
17
+ dC5jb20wHhcNMDkwMjI2MTk0NDU4WhcNMTExMTIzMTk0NDU4WjCBmzELMAkGA1UE
18
+ BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lz
19
+ Y28xEzARBgNVBAoTCldlYkdldC5jb20xEzARBgNVBAsTCldlYkdldC5jb20xEzAR
20
+ BgNVBAMTCldlYkdldC5jb20xIDAeBgkqhkiG9w0BCQEWEXdlYmdldEB3ZWJnZXQu
21
+ Y29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDXCFYfW6hCQl0ToNjaMIXG
22
+ ZfPF6OoR20BO/Tg6V37qPi7gDSZ6vIC6Mxcs8LtEcju85cD9lnKKl/lo4S5/w9Ha
23
+ hGD2ZFFfbF8420X5Za5G2KuriS3GzRz7F5dKCTjb1NH9TPlgOc71bcrDmCwwtFJl
24
+ T+tdfBju0YxLSBiMXf4y5QIDAQABo4IBBDCCAQAwHQYDVR0OBBYEFHB1kXO/Xd4g
25
+ G+AJ2/wwh6JOWXzNMIHQBgNVHSMEgcgwgcWAFHB1kXO/Xd4gG+AJ2/wwh6JOWXzN
26
+ oYGhpIGeMIGbMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQG
27
+ A1UEBxMNU2FuIEZyYW5jaXNjbzETMBEGA1UEChMKV2ViR2V0LmNvbTETMBEGA1UE
28
+ CxMKV2ViR2V0LmNvbTETMBEGA1UEAxMKV2ViR2V0LmNvbTEgMB4GCSqGSIb3DQEJ
29
+ ARYRd2ViZ2V0QHdlYmdldC5jb22CCQCJUqhJA0GmSDAMBgNVHRMEBTADAQH/MA0G
30
+ CSqGSIb3DQEBBQUAA4GBADzVXlwuff0/w3yK4LflGKKhtC3oChIrwmSyP6tk628N
31
+ BHokpc4Kz63xSXqzYTnBS7rFBwlYThtNalQeWmoUjGh3Z0ZR0JlhU0ln8899LuJ3
32
+ DXnLFY0cVuBnNDMOOFl8vk1qIcZjcTovhzgcixpG6Uk5qmUsKHRLQf4oQJx7TfLK
33
+ -----END CERTIFICATE-----
34
+
35
+ date: 2010-02-17 00:00:00 -08:00
36
+ default_executable:
37
+ dependencies: []
38
+
39
+ description:
40
+ email: webget@webget.com
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - lib/webget_ruby_password_hash.rb
49
+ has_rdoc: true
50
+ homepage: http://webget.com/
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ requirements: []
71
+
72
+ rubyforge_project:
73
+ rubygems_version: 1.3.5
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: "WebGet Ruby Gem: PasswordHash class for secure password hashing with plain text and random salt"
77
+ test_files:
78
+ - test/webget_ruby_password_hash_test.rb
metadata.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ p�[2�ҞSm
2
+ y`p2�
3
+ G!���,{������&��r+�L��i��i ��;�Z�%g�B��4��Q<�s�