|
25 | 25 | |bcrypt-x |2x |bug compatible |
|
26 | 26 | |bcrypt-y |2y |historic alias for 2b|
|
27 | 27 |
|
28 |
| - The third argument to this function is the salt to use. |
| 28 | + The third argument to this function is the salt to use. For bcrypt-type hashes, |
| 29 | + the first two characters of the salt represent a strength parameter, with a value |
| 30 | + between 4 and 31 inclusive. |
29 | 31 |
|
30 | 32 | @return [String]
|
31 | 33 | Provides a crypt hash usable on most POSIX systems.
|
|
48 | 50 | 'md5' => { prefix: '1' },
|
49 | 51 | 'sha-256' => { prefix: '5' },
|
50 | 52 | 'sha-512' => { prefix: '6' },
|
51 |
| - 'bcrypt' => { prefix: '2b', salt: %r{^[0-9]{2}\$[./A-Za-z0-9]{22}} }, |
52 |
| - 'bcrypt-a' => { prefix: '2a', salt: %r{^[0-9]{2}\$[./A-Za-z0-9]{22}} }, |
53 |
| - 'bcrypt-x' => { prefix: '2x', salt: %r{^[0-9]{2}\$[./A-Za-z0-9]{22}} }, |
54 |
| - 'bcrypt-y' => { prefix: '2y', salt: %r{^[0-9]{2}\$[./A-Za-z0-9]{22}} }, |
| 53 | + 'bcrypt' => { prefix: '2b', salt: %r{^(0[4-9]|[12][0-9]|3[01])\$[./A-Za-z0-9]{22}} }, |
| 54 | + 'bcrypt-a' => { prefix: '2a', salt: %r{^(0[4-9]|[12][0-9]|3[01])\$[./A-Za-z0-9]{22}} }, |
| 55 | + 'bcrypt-x' => { prefix: '2x', salt: %r{^(0[4-9]|[12][0-9]|3[01])\$[./A-Za-z0-9]{22}} }, |
| 56 | + 'bcrypt-y' => { prefix: '2y', salt: %r{^(0[4-9]|[12][0-9]|3[01])\$[./A-Za-z0-9]{22}} }, |
55 | 57 | }
|
56 | 58 |
|
57 | 59 | raise ArgumentError, 'pw_hash(): first argument must be a string' unless args[0].is_a?(String) || args[0].nil?
|
|
0 commit comments