remove use of sha module
This commit is contained in:
1 parent
80f00f7ec0
commit
85ef891ffd
4 files changed
+8
-36
No files matched your search
@@ -2,11 +2,7 @@
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
import datetime
|
||||
from decimal import Decimal
|
||||
try:
|
||||
import hashlib
|
||||
except ImportError:
|
||||
hashlib = None
|
||||
import sha
|
||||
import hashlib
|
||||
|
||||
|
||||
class Field(object):
|
||||
@@ -54,10 +50,7 @@ class Sha(Field):
|
||||
if value is not None:
|
||||
if isinstance(value, unicode):
|
||||
value = value.encode('utf-8')
|
||||
if hashlib:
|
||||
value = hashlib.sha1(value).hexdigest()
|
||||
else:
|
||||
value = sha.new(value).hexdigest()
|
||||
value = hashlib.sha1(value).hexdigest()
|
||||
return Char.sql_format(value)
|
||||
|
||||
|
||||
|
||||
@@ -5,11 +5,7 @@ import traceback
|
||||
import logging
|
||||
import time
|
||||
import sys
|
||||
try:
|
||||
import hashlib
|
||||
except ImportError:
|
||||
hashlib = None
|
||||
import sha
|
||||
import hashlib
|
||||
import pydoc
|
||||
from trytond.pool import Pool
|
||||
from trytond import security
|
||||
@@ -236,10 +232,7 @@ def create(database_name, password, lang, admin_password):
|
||||
cursor.limit_clause('SELECT id FROM ir_lang ' \
|
||||
'WHERE code = %s', 1) + ')' \
|
||||
'WHERE login <> \'root\'', (lang,))
|
||||
if hashlib:
|
||||
admin_password = hashlib.sha1(admin_password).hexdigest()
|
||||
else:
|
||||
admin_password = sha.new(admin_password).hexdigest()
|
||||
admin_password = hashlib.sha1(admin_password).hexdigest()
|
||||
cursor.execute('UPDATE res_user ' \
|
||||
'SET password = %s ' \
|
||||
'WHERE login = \'admin\'', (admin_password,))
|
||||
|
||||
+2
-9
@@ -4,11 +4,7 @@
|
||||
import copy
|
||||
import string
|
||||
import random
|
||||
try:
|
||||
import hashlib
|
||||
except ImportError:
|
||||
hashlib = None
|
||||
import sha
|
||||
import hashlib
|
||||
import time
|
||||
import datetime
|
||||
from itertools import groupby, ifilter
|
||||
@@ -460,10 +456,7 @@ class User(ModelSQL, ModelView):
|
||||
password += salt or ''
|
||||
if isinstance(password, unicode):
|
||||
password = password.encode('utf-8')
|
||||
if hashlib:
|
||||
password_sha = hashlib.sha1(password).hexdigest()
|
||||
else:
|
||||
password_sha = sha.new(password).hexdigest()
|
||||
password_sha = hashlib.sha1(password).hexdigest()
|
||||
cursor = Transaction().cursor
|
||||
if password_sha == user_password:
|
||||
cursor.execute('UPDATE "' + cls._table + '" '
|
||||
|
||||
+2
-9
@@ -11,11 +11,7 @@ import signal
|
||||
import time
|
||||
from trytond.config import CONFIG
|
||||
from getpass import getpass
|
||||
try:
|
||||
import hashlib
|
||||
except ImportError:
|
||||
hashlib = None
|
||||
import sha
|
||||
import hashlib
|
||||
import threading
|
||||
import string
|
||||
import random
|
||||
@@ -169,10 +165,7 @@ class TrytonServer(object):
|
||||
salt = ''.join(random.sample(
|
||||
string.letters + string.digits, 8))
|
||||
password += salt
|
||||
if hashlib:
|
||||
password = hashlib.sha1(password).hexdigest()
|
||||
else:
|
||||
password = sha.new(password).hexdigest()
|
||||
password = hashlib.sha1(password).hexdigest()
|
||||
cursor.execute('UPDATE res_user ' \
|
||||
'SET password = %s, salt = %s ' \
|
||||
'WHERE login = \'admin\'', (password, salt))
|
||||
|
||||
Reference in new issue
Block a user