Beispiel #1
0
    def test_generate_sha512(self):
        """
        Test sha512 generate and length
        """
        key = keygen.generate(hashlib.sha512, True)
        self.assertEqual(len(key), 86, "Wrong alphaonly length")

        key = keygen.generate(hashlib.sha512, False)
        self.assertEqual(len(key), 88, "Wrong generate length")
Beispiel #2
0
    def test_generate_sha256(self):
        """
        Test sha256 generate and length
        """
        key = keygen.generate(hashlib.sha256, True)
        self.assertEqual(len(key), 43, "Wrong alphaonly length")

        key = keygen.generate(hashlib.sha256, False)
        self.assertEqual(len(key), 44, "Wrong generate length")
Beispiel #3
0
    def test_generate_sha224(self):
        """
        Test sha224 generate and length
        """
        key = keygen.generate(hashlib.sha224, True)
        self.assertEqual(len(key), 38, "Wrong alphaonly length")

        key = keygen.generate(hashlib.sha224, False)
        self.assertEqual(len(key), 40, "Wrong generate length")
Beispiel #4
0
    def test_generate_sha1(self):
        """
        Test sha1 generate and length
        """
        key = keygen.generate(hashlib.sha1, True)
        self.assertEqual(len(key), 27, "Wrong alphaonly length")

        key = keygen.generate(hashlib.sha1, False)
        self.assertEqual(len(key), 28, "Wrong generate length")
Beispiel #5
0
    def test_generate_md5(self):
        """
        Test md5 generate and length
        """
        key = keygen.generate(hashlib.md5, True)
        self.assertEqual(len(key), 22, "Wrong alphaonly length")

        key = keygen.generate(hashlib.md5, False)
        self.assertEqual(len(key), 24, "Wrong generate length")
Beispiel #6
0
 def test_alphaonly_generate(self):
     """
     Ensure alphaonly generate is respected
     """
     key = keygen.generate(alphaonly=True)
     self.assertIsInstance(key, basestring)
     for char in key:
         self.assertIn(char, string.letters+string.digits)
Beispiel #7
0
 def keygen(self, **opts):
     return generate(hashlib.sha256, False)