Class: UnixCrypt::MD5
- Inherits:
-
Base
- Object
- Base
- UnixCrypt::MD5
show all
- Defined in:
- lib/unix_crypt/md5.rb
Class Method Summary
collapse
Methods inherited from Base
bit_specified_base64encode, build, construct_password, generate_salt, hash, prepare_password, rounds_marker
Class Method Details
.byte_indexes ⇒ Object
9
10
11
|
# File 'lib/unix_crypt/md5.rb', line 9
def self.byte_indexes
[[0, 6, 12], [1, 7, 13], [2, 8, 14], [3, 9, 15], [4, 10, 5], [nil, nil, 11]]
end
|
.default_salt_length ⇒ Object
5
|
# File 'lib/unix_crypt/md5.rb', line 5
def self.default_salt_length; 8; end
|
.digest ⇒ Object
3
|
# File 'lib/unix_crypt/md5.rb', line 3
def self.digest; Digest::MD5; end
|
.identifier ⇒ Object
7
|
# File 'lib/unix_crypt/md5.rb', line 7
def self.identifier; 1; end
|
.internal_hash(password, salt, ignored = nil) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/unix_crypt/md5.rb', line 13
def self.internal_hash(password, salt, ignored = nil)
salt = salt[0..7]
b = digest.digest("#{password}#{salt}#{password}")
a_string = "#{password}$1$#{salt}#{b * (password.length/length)}#{b[0...password.length % length]}"
password_length = password.length
while password_length > 0
a_string += (password_length & 1 != 0) ? "\x0" : password[0].chr
password_length >>= 1
end
input = digest.digest(a_string)
1000.times do |index|
c_string = ((index & 1 != 0) ? password : input)
c_string += salt unless index % 3 == 0
c_string += password unless index % 7 == 0
c_string += ((index & 1 != 0) ? input : password)
input = digest.digest(c_string)
end
input
end
|
.length ⇒ Object
4
|
# File 'lib/unix_crypt/md5.rb', line 4
def self.length; 16; end
|
.max_salt_length ⇒ Object
6
|
# File 'lib/unix_crypt/md5.rb', line 6
def self.max_salt_length; 8; end
|