Example #1
0
def md5(s, encoding='utf8') -> str:
    if isinstance(s, str):
        b = s.encode(encoding)
    elif isinstance(s, bytes):
        b = s
    else:
        b = str(s).encode(encoding)
    h = __md5()
    h.update(b)
    return h.hexdigest()
def __md5digest(filename):
	"""
	For internal use only.
	"""
	m = __md5()
	f = open(filename)
	while True:
		d = f.read(4096)
		if not d:
			break
		m.update(d)
	return m.hexdigest()
Example #3
0
def hashHex(filepath,blocksize=65536): #65536
    """Return the MD5 hash of the file at $filepath as a string"""
    with open(filepath,'rb') as file:
        hasher = __md5()
        while len(buffer := file.read(blocksize)) > 0:
            hasher.update(buffer)
Example #4
0
# $Id: auth.py,v 1.41 2008/09/13 21:45:21 normanr Exp $

"""
Provides library with all Non-SASL and SASL authentication mechanisms.
Can be used both for client and transport authentication.
"""

from protocol import *
from client import PlugIn
from random import random as _random
from hashlib import md5 as __md5
from re import findall as re_findall
from base64 import encodestring, decodestring
import dispatcher

HH = lambda some: __md5(some).hexdigest()
H = lambda some: __md5(some).digest()
C = lambda some: ':'.join(some)

class NonSASL(PlugIn):
	""" Implements old Non-SASL (JEP-0078) authentication used in jabberd1.4 and transport authentication."""
	def __init__(self,user,password,resource):
		""" Caches username, password and resource for auth. """
		PlugIn.__init__(self)
		self.DBG_LINE='gen_auth'
		self.user=user
		self.password=password
		self.resource=resource

	def plugin(self,owner):
		""" Determine the best auth method (digest/0k/plain) and use it for auth.
Example #5
0
def H(some):
    return __md5(some).digest()
Example #6
0
def HH(some):
    return __md5(some).hexdigest()
Example #7
0
def H(some):
	return __md5(some).digest()
Example #8
0
def HH(some):
	return __md5(some).hexdigest()