HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //proc/thread-self/root/usr/share/doc/m2crypto-0.21.1/demo/perf/sha1.py
#!/usr/bin/python2.0

"""A comparison of Python's sha and M2Crypto.EVP.MessageDigest, 
the outcome of which is that EVP.MessageDigest suffers from doing 
too much in Python."""

import profile

from sha import sha
import M2Crypto
from M2Crypto import m2
from M2Crypto.EVP import MessageDigest

txt = 'Python, Smalltalk, Haskell, Scheme, Lisp, Self, Erlang, ML, ...'

def py_sha(iter, txt=txt):
    s = sha()
    for i in range(iter):
        s.update(txt)
    out = s.digest()

def m2_sha(iter, txt=txt):
    s = MessageDigest('sha1')
    for i in range(iter):
        s.update(txt)
    out = s.digest()

def m2_sha_2(iter, txt=txt):
    s = MessageDigest('sha1')
    s.update(txt * iter)
    out = s.digest()

def m2c_sha(iter, txt=txt):
    ctx = m2.md_ctx_new()
    m2.digest_init(ctx, m2.sha1())
    for i in range(iter):
        m2.digest_update(ctx, txt)
    out = m2.digest_final(ctx)

if __name__ == '__main__':
    profile.run('py_sha(10000)')
    profile.run('m2_sha(10000)')
    profile.run('m2_sha_2(10000)')
    profile.run('m2c_sha(10000)')