GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

src.pyejabberd._format_digest()   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 11
rs 9.2
cc 4
1
# -*- coding: utf-8 -*-
2
from __future__ import unicode_literals
3
from builtins import range, int
4
5
import hashlib
6
7
from six import b
8
9
10
def _format_digest(hexdigest):  # pragma: no cover
11
    parts = []
12
    hexdigest_size = int(len(hexdigest) / 2)
13
    for i in range(hexdigest_size):
14
        part = hexdigest[i * 2:(i * 2) + 2]
15
        if part == '00':
16
            part = ''
17
        elif part.startswith('0'):
18
            part = part[1:]
19
        parts.append(part)
20
    return (''.join(parts)).upper()
21
22
23
def _format_password_hash(password, hash_method):  # pragma: no cover
24
    hash_method.update(b(password))
25
    return _format_digest(hash_method.hexdigest())
26
27
28
def format_password_hash_sha(password):
29
    return _format_password_hash(password, hashlib.sha1())
30
31
32
def format_password_hash_md5(password):
33
    return _format_password_hash(password, hashlib.md5())
34