Esempio n. 1
0
def demo1():
    print 'Test 1: As DER...'
    cert1 = X509.load_cert('server.pem')
    der1 = cert1.as_der()
    dgst1 = MessageDigest('sha1')
    dgst1.update(der1)
    print 'Using M2Crypto:\n', ` dgst1.final() `, '\n'

    cert2 = os.popen('openssl x509 -inform pem -outform der -in server.pem')
    der2 = cert2.read()
    dgst2 = MessageDigest('sha1')
    dgst2.update(der2)
    print 'Openssl command line:\n', ` dgst2.final() `, '\n'
Esempio n. 2
0
def md5(buf):
    b = MessageDigest('md5')
    b.update(buf)
    b.update('888')
    c = b.digest()
    s = ''
    for i in c:
        s = s + '%02x' % ord(i)
    return s
def M2Crypto_SHA1():
    global encryptionavg
    global decryptionavg
    from M2Crypto.EVP import MessageDigest
    startTime = time.time()
    h = MessageDigest('sha1')
    h.update(plainContent)
    totalTime = time.time() - startTime
    encryptionavg += totalTime
    #print totalTime
    print('SHA1 Hash: Total time: %.5f seconds' % totalTime)
Esempio n. 4
0
def m2_sha_2(iter, txt=txt):
    s = MessageDigest('sha1')
    s.update(txt * iter)
    out = s.digest()
Esempio n. 5
0
def m2_sha(iter, txt=txt):
    s = MessageDigest('sha1')
    for i in range(iter):
        s.update(txt)
    out = s.digest()
Esempio n. 6
0
def fingerprint(x509):
    der = x509.as_der()
    md = MessageDigest('sha1')
    md.update(der)
    digest = md.final()
    return hex(util.octx_to_num(digest))