# Path: oslo_utils/secretutils.py
# def _constant_time_compare(first, second):
#     def md5(string=b'', usedforsecurity=True):
#     def md5(string=b'', usedforsecurity=True):


import hashlib
import hmac
import testscenarios
from oslotest import base as test_base
from oslo_utils import secretutils
        digest = secretutils.md5(self._test_data,
                                 usedforsecurity=True).digest()
        self.assertEqual(digest, self._md5_digest)

        digest = secretutils.md5(self._test_data,
                                 usedforsecurity=False).digest()
        self.assertEqual(digest, self._md5_digest)

    def test_md5_without_data(self):
        md5 = secretutils.md5()
        md5.update(self._test_data)
        digest = md5.digest()
        self.assertEqual(digest, self._md5_digest)

        md5 = secretutils.md5(usedforsecurity=True)
        md5.update(self._test_data)
        digest = md5.digest()
        self.assertEqual(digest, self._md5_digest)

        md5 = secretutils.md5(usedforsecurity=False)
        md5.update(self._test_data)
        digest = md5.digest()
        self.assertEqual(digest, self._md5_digest)

    def test_string_data_raises_type_error(self):
        self.assertRaises(TypeError, hashlib.md5, 'foo')
        self.assertRaises(TypeError, secretutils.md5, 'foo')
        self.assertRaises(
            TypeError, secretutils.md5, 'foo', usedforsecurity=True)
        self.assertRaises(

# Path: oslo_utils/secretutils.py
# def _constant_time_compare(first, second):
#     def md5(string=b'', usedforsecurity=True):
#     def md5(string=b'', usedforsecurity=True):


# Path: oslo_utils/tests/test_secretutils.py
import hashlib
import hmac
import testscenarios
from oslotest import base as test_base
from oslo_utils import secretutils

        digest = secretutils.md5(self._test_data,
                                 usedforsecurity=True).digest()
        self.assertEqual(digest, self._md5_digest)

        digest = secretutils.md5(self._test_data,
                                 usedforsecurity=False).digest()
        self.assertEqual(digest, self._md5_digest)

    def test_md5_without_data(self):
        md5 = secretutils.md5()
        md5.update(self._test_data)
        digest = md5.digest()
        self.assertEqual(digest, self._md5_digest)

        md5 = secretutils.md5(usedforsecurity=True)
        md5.update(self._test_data)
        digest = md5.digest()
        self.assertEqual(digest, self._md5_digest)

        md5 = secretutils.md5(usedforsecurity=False)
        md5.update(self._test_data)
        digest = md5.digest()
        self.assertEqual(digest, self._md5_digest)

    def test_string_data_raises_type_error(self):
        self.assertRaises(TypeError, hashlib.md5, 'foo')
        self.assertRaises(TypeError, secretutils.md5, 'foo')
        self.assertRaises(
            TypeError, secretutils.md5, 'foo', usedforsecurity=True)
        self.assertRaises(

            TypeError, secretutils.md5, 'foo', usedforsecurity=False)