|
@@ -252,6 +252,17 @@ class Demeter(object):
|
|
|
else:
|
|
|
return hashlib.md5(value.encode("utf-8")).hexdigest()
|
|
|
|
|
|
+ @classmethod
|
|
|
+ def sha1(self, value, salt=False):
|
|
|
+ import hashlib
|
|
|
+ if salt:
|
|
|
+ if salt == True:
|
|
|
+ salt = self.rand()
|
|
|
+ value = value + salt
|
|
|
+ return hashlib.sha1(value.encode("utf-8")).hexdigest() + '_' + salt
|
|
|
+ else:
|
|
|
+ return hashlib.sha1(value.encode("utf-8")).hexdigest()
|
|
|
+
|
|
|
@classmethod
|
|
|
def rand(self, length = 4):
|
|
|
module = self.getObject('random')
|
|
@@ -394,6 +405,20 @@ class File(object):
|
|
|
content = handle.read()
|
|
|
handle.close()
|
|
|
return content
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def readContent(path, name = ''):
|
|
|
+ content = ''
|
|
|
+ handle = open(path + name, 'r')
|
|
|
+ while True:
|
|
|
+ line = handle.readline()
|
|
|
+ if line:
|
|
|
+ line = line.rstrip("\n")
|
|
|
+ content = content + line
|
|
|
+ else:
|
|
|
+ break
|
|
|
+ handle.close()
|
|
|
+ return content
|
|
|
|
|
|
@staticmethod
|
|
|
def cur_path():
|