HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/mysqlsh/lib/python3.8/site-packages/oci/object_storage/transfer/internal/md5.py
# coding: utf-8
# Copyright (c) 2016, 2025, Oracle and/or its affiliates.  All rights reserved.
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes


class md5:
    """
    Wrapper for MD5 implementation in cryptography for when the hashlib MD5
    implementation has be turned off due to FIPS
    """

    def __init__(self):
        self._digest = hashes.Hash(hashes.MD5(), backend=default_backend())

    def update(self, message):
        data = message
        if isinstance(message, memoryview):
            data = message.tobytes()

        self._digest.update(data)

    def digest(self):
        return self._digest.finalize()