Ejemplo n.º 1
0
 def generate_random_password(self, size=10):
     """
     Generates random password of given size
     it ensures -
     1 uppercase
     1 lowercase
     1 digit
     1 punc
     """
     P = [random.choice(s) for s in self.must_set]
     P.extend([random.choice(self.All)
               for n in range(size - len(self.must_set))])
     n = random.randint(0, MAX_INT)
     password = self.decode2string(n, P)
     return password
Ejemplo n.º 2
0
    def test_enc_dec_vault_size(self):
        vd = pcfg.VaultDistPCFG()
        X = vd.encode_vault_size('D', 3)
        t = vd.decode_vault_size('D', X)
        self.assertEqual(t, 3, str((X, t)))

        for i in range(25):
            k = random.randint(1, pcfg.MAX_ALLOWED)
            lhs = random.choice(vd.G.keys())
            e = vd.encode_vault_size(lhs, k)
            self.assertEqual(vd.decode_vault_size(lhs, e), k, "VaultSizeDecodingError:"\
              " Expecting: {} for (lhs: {}, e:{}), but decoded to: {}"\
              .format(k, lhs, e, vd.decode_vault_size(lhs, e)))
Ejemplo n.º 3
0
 def test_enc_dec_vault_size(self):
     vd = pcfg.VaultDistPCFG()
     X = vd.encode_vault_size('D', 3)
     t = vd.decode_vault_size('D', X)
     self.assertEqual(t, 3, str((X, t)))
     
     for i in range(25):
         k = random.randint(1,pcfg.MAX_ALLOWED)
         lhs = random.choice(vd.G.keys())
         e = vd.encode_vault_size(lhs, k)
         self.assertEqual(vd.decode_vault_size(lhs, e), k, "VaultSizeDecodingError:"\
           " Expecting: {} for (lhs: {}, e:{}), but decoded to: {}"\
           .format(k, lhs, e, vd.decode_vault_size(lhs, e)))