cram_md5 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Gemfile +3 -1
  2. data/lib/cram_md5/version.rb +1 -1
  3. data/lib/cram_md5.rb +13 -2
  4. metadata +25 -48
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source :rubygems
2
2
 
3
3
  # Specify your gem's dependencies in cram_md5.gemspec
4
4
  gemspec
5
+
6
+ gem "rspec"
@@ -1,3 +1,3 @@
1
1
  module CramMd5
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/cram_md5.rb CHANGED
@@ -15,8 +15,20 @@ module CramMd5
15
15
  end
16
16
  ret
17
17
  end
18
+
19
+ # Returns Salt from a password
20
+ #
21
+ # @param [String] password An unix md5 crypted password
22
+ # @return [String] salt The Sal from the crypted password
23
+ # @return [Nil] if the password is invalid
24
+ def self.salt(password)
25
+ if password =~ /\$.+\$.+\$/ and password.length > 30
26
+ return $1 if password =~ /\$.+\$(.+)\$/
27
+ end
28
+ nil
29
+ end
18
30
 
19
- def self.apache_md5_crypt (pw, salt)
31
+ def self.apache_md5_crypt(pw, salt)
20
32
  self.unix_md5_crypt(pw, salt, '$apr1$')
21
33
  end
22
34
 
@@ -25,7 +37,6 @@ module CramMd5
25
37
  #@params [string] magic
26
38
  #@note For compare, use de original password and the salt of encrypted password.
27
39
  #@return [string] crypt pass
28
-
29
40
  def self.unix_md5_crypt(pw, salt="", magic=nil)
30
41
 
31
42
  if magic==nil
metadata CHANGED
@@ -1,38 +1,25 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cram_md5
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Thiago Coutinho
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-09-25 00:00:00 -03:00
19
- default_executable:
12
+ date: 2012-10-08 00:00:00.000000000Z
20
13
  dependencies: []
21
-
22
- description: |-
23
-
24
- unix_md5_crypt() provides a crypt()-compatible interface to the
25
- rather old MD5-based crypt() function found in modern operating systems
26
- using old and solid libs.
27
- email:
14
+ description: ! "\n unix_md5_crypt() provides a crypt()-compatible interface to the\n
15
+ \ rather old MD5-based crypt() function found in modern operating systems\n using
16
+ old and solid libs."
17
+ email:
28
18
  - thiago.coutinho@locaweb.com.br
29
19
  executables: []
30
-
31
20
  extensions: []
32
-
33
21
  extra_rdoc_files: []
34
-
35
- files:
22
+ files:
36
23
  - Gemfile
37
24
  - LICENSE
38
25
  - README.md
@@ -40,39 +27,29 @@ files:
40
27
  - cram_md5.gemspec
41
28
  - lib/cram_md5.rb
42
29
  - lib/cram_md5/version.rb
43
- has_rdoc: true
44
- homepage: ""
30
+ homepage: ''
45
31
  licenses: []
46
-
47
32
  post_install_message:
48
33
  rdoc_options: []
49
-
50
- require_paths:
34
+ require_paths:
51
35
  - lib
52
- required_ruby_version: !ruby/object:Gem::Requirement
36
+ required_ruby_version: !ruby/object:Gem::Requirement
53
37
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
61
- required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
43
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- hash: 3
67
- segments:
68
- - 0
69
- version: "0"
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
70
48
  requirements: []
71
-
72
49
  rubyforge_project:
73
- rubygems_version: 1.3.7
50
+ rubygems_version: 1.8.15
74
51
  signing_key:
75
52
  specification_version: 3
76
53
  summary: unix_md5_crypt CRAM-MD5 or Crypt MD5
77
54
  test_files: []
78
-
55
+ has_rdoc: