def warp_password(self):
        """Warps around the chars in the password."""
        import string

        warps = {}
        # add the alphabet to the warplist
        for x in xrange(ord('a'), ord('z')+1):
            x = chr(x)
            warps[x] = [x, x.upper()]

        # add some specials
        specialchars = (("a", ["@", "4"]),
                        ("e", ["3"]),
                        ("g", ["6"]),
                        ("i", ["1", "|", "!"]),
                        ("l", ["1", "|", "!"]),
                        ("o", ["0"]),
                        ("s", ["5", "z", "Z"]),
                        ("t", ["+", "7"]),
                        ("z", ["s", "S", "2"]))

        for (a,b) in specialchars:
            warps[a] += b

        randoms = 0
        warped_password = ""
        # warp the chars in the password
        for i in self.password:
            if i in warps.keys():
                # 75% probability
                if randint(0, 3):
                    warped_password += choice(warps[i])
                else:
                    warped_password += i
            else:
                warped_password += i

            # add a random character (max two)
            if randint(0, 5) == 0 and randoms < 2:
                warped_password += choice("\/_.,!;:'+-=")
                randoms += 1

#        print "unwarped pass = ", self.password
#        print "warped pass   = ", warped_password

        return warped_password
Warps around the chars in the password.
recipes/Python/65217_Password_generator/recipe-65217.py