Commit 03e08980 authored by Vincent Pelletier's avatar Vincent Pelletier

Make it possible to compute SHA and MD5 sums from restricted code.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25615 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b9bd3686
......@@ -31,6 +31,8 @@ import os
import re
import string
import time
from md5 import new as md5_new
from sha import new as sha_new
from Globals import package_home
from Globals import DevelopmentMode
......@@ -39,6 +41,8 @@ from Acquisition import aq_inner
from Acquisition import aq_parent
from Acquisition import aq_self
from AccessControl.SecurityInfo import allow_class
from Products.CMFCore import utils
from Products.CMFCore.Expression import Expression
from Products.CMFCore.DirectoryView import registerDirectory
......@@ -2726,3 +2730,35 @@ def sqlquote(x):
raise TypeError, 'do not know how to handle type %s' % type(x)
return x
#####################################################
# Hashing
#####################################################
class GenericSum:
def __init__(self, sum):
self.sum = sum
def digest(self):
return self.sum.digest()
def hexdigest(self):
return self.sum.hexdigest()
def update(self, data):
self.sum.update(data)
def copy(self):
return self.__class__(self.sum.copy())
class md5(GenericSum):
def __init__(self, *args):
GenericSum.__init__(self, md5_new(*args))
allow_class(md5)
class sha(GenericSum):
def __init__(self, *args):
GenericSum.__init__(self, sha_new(*args))
allow_class(sha)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment