示例#1
0
def request_mai_id():
    """Generate an unused mai_id."""
    max_tries = 20
    found = False

    for i in range(max_tries):
        mai_id = crypto.sha512_hash_hex(str(request.headers) + str(time.time()))
        if MetaAppInstance.objects(mai_id=mai_id).count() == 0:
            found = True
            break

    if not found:
        abort(500)

    return mai_id
示例#2
0
    def test_sha512_hash_hex(self):
        self.sha.update(self.string1)
        h1hex = self.sha.hexdigest()

        assert crypto.sha512_hash_hex(self.string2) != h1hex
        assert crypto.sha512_hash_hex(self.string1) == h1hex