Server IP : 85.214.239.14 / Your IP : 18.117.231.160 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /srv/modoboa/env/lib64/python3.5/site-packages/oath/ |
Upload File : |
try: from functools import reduce except ImportError: # not necesary in Python 2.x pass if hasattr(bytes, 'fromhex'): # Python 3.x import binascii def fromhex(s): return bytes.fromhex(s) def tohex(bin): return binascii.hexlify(bin).decode('ascii') else: # Python 2.x def fromhex(s): return s.decode('hex') def tohex(bin): return bin.encode('hex') def tobytes(b_or_s): try: if isinstance(b_or_s, bytes): return b_or_s except NameError: if isinstance(b_or_s, str): return b_or_s return b_or_s.encode('utf8') def compare_digest(a, b): if not hasattr(bytes, 'fromhex'): # Python 2 if isinstance(a, unicode): a = a.decode('ascii') if isinstance(b, unicode): a = a.decode('ascii') if type(a) != type(b): raise TypeError('compared digest must be of the same type') if hasattr(bytes, 'fromhex'): # Python 3 if not isinstance(a, (bytes, str)): raise TypeError('digest must be bytes or str') else: # Python 2 if not isinstance(a, (str, unicode)): raise TypeError('digest must be str or unicode') if len(a) != len(b): return False return all(map(lambda x: x[0] == x[1], zip(a, b)))