コード例 #1
0
ファイル: windows.py プロジェクト: thebaron/passlib
    def raw(cls, secret, user):
        """encode password using mscash v1 algorithm

        :arg secret: secret as unicode or utf-8 encoded bytes
        :arg user: username to use as salt

        :returns: returns string of raw bytes
        """
        secret = to_unicode(secret, "utf-8", param="secret").encode("utf-16-le")
        user = to_unicode(user, "utf-8", param="user").lower().encode("utf-16-le")
        return md4(md4(secret).digest() + user).digest()
コード例 #2
0
    def test_md4_hexdigest(self):
        "test md4 hexdigest()"
        from passlib.utils.md4 import md4

        for input, hex in self.vectors:
            out = md4(input).hexdigest()
            self.assertEqual(out, hex)
コード例 #3
0
ファイル: windows.py プロジェクト: thebaron/passlib
    def raw(cls, secret, user):
        """encode password using msdcc v2 algorithm

        :type secret: unicode or utf-8 bytes
        :arg secret: secret

        :type user: str
        :arg user: username to use as salt

        :returns: returns string of raw bytes
        """
        from passlib.utils.pbkdf2 import pbkdf2
        secret = to_unicode(secret, "utf-8", param="secret").encode("utf-16-le")
        user = to_unicode(user, "utf-8", param="user").lower().encode("utf-16-le")
        tmp = md4(md4(secret).digest() + user).digest()
        return pbkdf2(tmp, user, 10240, 16, 'hmac-sha1')
コード例 #4
0
    def test_md4_digest(self):
        "test md4 digest()"
        from passlib.utils.md4 import md4

        for input, hex in self.vectors:
            out = bascii_to_str(hexlify(md4(input).digest()))
            self.assertEqual(out, hex)
コード例 #5
0
ファイル: windows.py プロジェクト: marta90/Projekt
    def raw(cls, secret):
        """encode password using MD4-based NTHASH algorithm

        :arg secret: secret as unicode or utf-8 encoded bytes

        :returns: returns string of raw bytes
        """
        secret = to_unicode(secret, "utf-8", param="secret")
        # XXX: found refs that say only first 128 chars are used.
        return md4(secret.encode("utf-16-le")).digest()
コード例 #6
0
ファイル: windows.py プロジェクト: cutso/passlib
    def raw(cls, secret):
        """encode password using MD4-based NTHASH algorithm

        :arg secret: secret as unicode or utf-8 encoded bytes

        :returns: returns string of raw bytes
        """
        secret = to_unicode(secret, "utf-8", param="secret")
        # XXX: found refs that say only first 128 chars are used.
        return md4(secret.encode("utf-16-le")).digest()
コード例 #7
0
    def test_md4_copy(self):
        """test md4 copy()"""
        from passlib.utils.md4 import md4
        h = md4(b('abc'))

        h2 = h.copy()
        h2.update(b('def'))
        self.assertEqual(h2.hexdigest(), '804e7f1c2586e50b49ac65db5b645131')

        h.update(b('ghi'))
        self.assertEqual(h.hexdigest(), 'c5225580bfe176f6deeee33dee98732c')
コード例 #8
0
    def test_md4_copy(self):
        "test md4 copy()"
        from passlib.utils.md4 import md4
        h = md4(b('abc'))

        h2 = h.copy()
        h2.update(b('def'))
        self.assertEqual(h2.hexdigest(), '804e7f1c2586e50b49ac65db5b645131')

        h.update(b('ghi'))
        self.assertEqual(h.hexdigest(), 'c5225580bfe176f6deeee33dee98732c')
コード例 #9
0
    def test_md4_copy(self):
        "test md4 copy()"
        from passlib.utils.md4 import md4

        h = md4(b("abc"))

        h2 = h.copy()
        h2.update(b("def"))
        self.assertEqual(h2.hexdigest(), "804e7f1c2586e50b49ac65db5b645131")

        h.update(b("ghi"))
        self.assertEqual(h.hexdigest(), "c5225580bfe176f6deeee33dee98732c")
コード例 #10
0
ファイル: nthash.py プロジェクト: GabrielDiniz/FluxNetControl
    def raw_nthash(secret, hex=False):
        """encode password using md4-based NTHASH algorithm

        :returns:
            returns string of raw bytes if ``hex=False``,
            returns digest as hexidecimal unicode if ``hex=True``.
        """
        secret = to_unicode(secret, "utf-8")
        hash = md4(secret.encode("utf-16le"))
        if hex:
            return to_unicode(hash.hexdigest(), 'ascii')
        else:
            return hash.digest()
コード例 #11
0
    def raw_nthash(secret, hex=False):
        """encode password using md4-based NTHASH algorithm

        :returns:
            returns string of raw bytes if ``hex=False``,
            returns digest as hexidecimal unicode if ``hex=True``.
        """
        secret = to_unicode(secret, "utf-8")
        hash = md4(secret.encode("utf-16le"))
        if hex:
            return to_unicode(hash.hexdigest(), 'ascii')
        else:
            return hash.digest()
コード例 #12
0
    def test_md4_update(self):
        """test md4 update"""
        from passlib.utils.md4 import md4
        h = md4(b(''))
        self.assertEqual(h.hexdigest(), "31d6cfe0d16ae931b73c59d7e0c089c0")

        # NOTE: under py2, hashlib methods try to encode to ascii,
        #       though shouldn't rely on that.
        if PY3 or self._disable_native:
            self.assertRaises(TypeError, h.update, u('x'))

        h.update(b('a'))
        self.assertEqual(h.hexdigest(), "bde52cb31de33e46245e05fbdbd6fb24")

        h.update(b('bcdefghijklmnopqrstuvwxyz'))
        self.assertEqual(h.hexdigest(), "d79e1c308aa5bbcdeea8ed63df412da9")
コード例 #13
0
    def test_md4_update(self):
        "test md4 update"
        from passlib.utils.md4 import md4
        h = md4(b(''))
        self.assertEqual(h.hexdigest(), "31d6cfe0d16ae931b73c59d7e0c089c0")

        # NOTE: under py2, hashlib methods try to encode to ascii,
        #       though shouldn't rely on that.
        if PY3 or self._disable_native:
            self.assertRaises(TypeError, h.update, u('x'))

        h.update(b('a'))
        self.assertEqual(h.hexdigest(), "bde52cb31de33e46245e05fbdbd6fb24")

        h.update(b('bcdefghijklmnopqrstuvwxyz'))
        self.assertEqual(h.hexdigest(), "d79e1c308aa5bbcdeea8ed63df412da9")
コード例 #14
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def _getPasswordHashHash(self, nthash):
     digest = md4()
     digest.update(nthash)
     return digest.digest()
コード例 #15
0
 def _getPasswordHashHash(self, nthash):
     digest = md4()
     digest.update(nthash)
     return digest.digest()
コード例 #16
0
 def test_md4_digest(self):
     "test md4 digest()"
     from passlib.utils.md4 import md4
     for input, hex in self.vectors:
         out = bascii_to_str(hexlify(md4(input).digest()))
         self.assertEqual(out, hex)
コード例 #17
0
 def test_md4_hexdigest(self):
     "test md4 hexdigest()"
     from passlib.utils.md4 import md4
     for input, hex in self.vectors:
         out = md4(input).hexdigest()
         self.assertEqual(out, hex)