Module refinery.units.crypto.hash.cryptographic

Implements various cryptographic hashing algorithms.

Expand source code Browse git
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Implements various cryptographic hashing algorithms.
"""
import hashlib

from . import HashUnit


class md4(HashUnit):
    """
    Returns the MD5 hash of the input data.
    """
    def _algorithm(self, data):
        from Crypto.Hash import MD4
        return MD4.new(data)


class md2(HashUnit):
    """
    Returns the MD5 hash of the input data.
    """
    def _algorithm(self, data):
        from Crypto.Hash import MD2
        return MD2.new(data)


class md5(HashUnit):
    """
    Returns the MD5 hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.md5(data)


class sha1(HashUnit):
    """
    Returns the SHA1 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.sha1(data)


class sha224(HashUnit):
    """
    Returns the SHA224 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.sha224(data)


class sha256(HashUnit):
    """
    Returns the SHA256 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.sha256(data)


class sha384(HashUnit):
    """
    Returns the SHA384 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.sha384(data)


class sha512(HashUnit):
    """
    Returns the SHA512 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.sha512(data)


class blk224(HashUnit):
    """
    Returns the BLK224 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.blake2b(data, digest_size=28)


class blk256(HashUnit):
    """
    Returns the BLK256 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.blake2b(data, digest_size=32)


class blk384(HashUnit):
    """
    Returns the BLK384 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.blake2b(data, digest_size=48)


class blk512(HashUnit):
    """
    Returns the BLK512 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.blake2b(data, digest_size=64)

Classes

class md4 (text=False)

Returns the MD5 hash of the input data.

Expand source code Browse git
class md4(HashUnit):
    """
    Returns the MD5 hash of the input data.
    """
    def _algorithm(self, data):
        from Crypto.Hash import MD4
        return MD4.new(data)

Ancestors

Inherited members

class md2 (text=False)

Returns the MD5 hash of the input data.

Expand source code Browse git
class md2(HashUnit):
    """
    Returns the MD5 hash of the input data.
    """
    def _algorithm(self, data):
        from Crypto.Hash import MD2
        return MD2.new(data)

Ancestors

Inherited members

class md5 (text=False)

Returns the MD5 hash of the input data.

Expand source code Browse git
class md5(HashUnit):
    """
    Returns the MD5 hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.md5(data)

Ancestors

Inherited members

class sha1 (text=False)

Returns the SHA1 Hash of the input data.

Expand source code Browse git
class sha1(HashUnit):
    """
    Returns the SHA1 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.sha1(data)

Ancestors

Inherited members

class sha224 (text=False)

Returns the SHA224 Hash of the input data.

Expand source code Browse git
class sha224(HashUnit):
    """
    Returns the SHA224 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.sha224(data)

Ancestors

Inherited members

class sha256 (text=False)

Returns the SHA256 Hash of the input data.

Expand source code Browse git
class sha256(HashUnit):
    """
    Returns the SHA256 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.sha256(data)

Ancestors

Inherited members

class sha384 (text=False)

Returns the SHA384 Hash of the input data.

Expand source code Browse git
class sha384(HashUnit):
    """
    Returns the SHA384 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.sha384(data)

Ancestors

Inherited members

class sha512 (text=False)

Returns the SHA512 Hash of the input data.

Expand source code Browse git
class sha512(HashUnit):
    """
    Returns the SHA512 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.sha512(data)

Ancestors

Inherited members

class blk224 (text=False)

Returns the BLK224 Hash of the input data.

Expand source code Browse git
class blk224(HashUnit):
    """
    Returns the BLK224 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.blake2b(data, digest_size=28)

Ancestors

Inherited members

class blk256 (text=False)

Returns the BLK256 Hash of the input data.

Expand source code Browse git
class blk256(HashUnit):
    """
    Returns the BLK256 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.blake2b(data, digest_size=32)

Ancestors

Inherited members

class blk384 (text=False)

Returns the BLK384 Hash of the input data.

Expand source code Browse git
class blk384(HashUnit):
    """
    Returns the BLK384 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.blake2b(data, digest_size=48)

Ancestors

Inherited members

class blk512 (text=False)

Returns the BLK512 Hash of the input data.

Expand source code Browse git
class blk512(HashUnit):
    """
    Returns the BLK512 Hash of the input data.
    """
    def _algorithm(self, data):
        return hashlib.blake2b(data, digest_size=64)

Ancestors

Inherited members