##// END OF EJS Templates
merged freebsd support issue from default
marcink -
r1195:74251f80 beta
parent child Browse files
Show More
@@ -36,11 +36,11 b' from pylons import config, session, url,'
36 36 from pylons.controllers.util import abort, redirect
37 37 from pylons.i18n.translation import _
38 38
39 from rhodecode import __platform__
39 from rhodecode import __platform__, PLATFORM_WIN, PLATFORM_OTHERS
40 40
41 if __platform__ == 'Windows':
41 if __platform__ in PLATFORM_WIN:
42 42 from hashlib import sha256
43 if __platform__ in ('Linux', 'Darwin'):
43 if __platform__ in PLATFORM_OTHERS:
44 44 import bcrypt
45 45
46 46 from rhodecode.lib import str2bool
@@ -90,12 +90,12 b' class RhodeCodeCrypto(object):'
90 90
91 91 :param password: password to hash
92 92 """
93 if __platform__ == 'Windows':
93 if __platform__ in PLATFORM_WIN:
94 94 return sha256(str_).hexdigest()
95 elif __platform__ in ('Linux', 'Darwin'):
95 elif __platform__ in PLATFORM_OTHERS:
96 96 return bcrypt.hashpw(str_, bcrypt.gensalt(10))
97 97 else:
98 raise Exception('Unknown or unsupoprted platform %s' % __platform__)
98 raise Exception('Unknown or unsupported platform %s' % __platform__)
99 99
100 100 @classmethod
101 101 def hash_check(cls, password, hashed):
@@ -107,15 +107,12 b' class RhodeCodeCrypto(object):'
107 107 :param hashed: password in hashed form
108 108 """
109 109
110 if __platform__ == 'Windows':
110 if __platform__ in PLATFORM_WIN:
111 111 return sha256(password).hexdigest() == hashed
112 elif __platform__ in ('Linux', 'Darwin'):
112 elif __platform__ in PLATFORM_OTHERS:
113 113 return bcrypt.hashpw(password, hashed) == hashed
114 114 else:
115 raise Exception('Unknown or unsupoprted platform %s' % __platform__)
116
117
118
115 raise Exception('Unknown or unsupported platform %s' % __platform__)
119 116
120 117
121 118 def get_crypt_password(password):
General Comments 0
You need to be logged in to leave comments. Login now