In [50]:
import random,string


def get_key(line):
    keylen=[]
    key_len=[]
    lenth=[]
    for word in line:
        lenth.append(len(word))
    n=len(line)
    for i in range(0,n):
        key_len.append(str(random.randint(100000000,1000000000)))
    for j in range(0,n):
        keylen.append(str(key_len[j])+str(lenth[j]))
    return keylen

def get_letter(line):
    key=get_key(line)#密码
    key_=line#原始
    str_tol=[]
    for i in range(len(line)):
        str_=''
        for j in range(len(key_[i])):
            a=ord(key_[i][j])
            b=int(key[i][j])
            if 99<=(a+b)<=122:
                str_+=chr(a+b)
            else:
                str_+=chr(a+b-26)
        str_tol.append(str_)
    return str_tol

def get_letter_(line):
    letter_=line
    letter=[]
    letter__=get_letter(line)
    for i in range(len(line)):
        letter.append(str(letter__[i])+''.join(random.sample(string.ascii_letters,(10-(len(letter__[i]))))))
        letter[i]=letter[i].lower()
    return letter


    


fh=open(r'd:\temp\code.txt')
text=fh.read()
text=text.split()
fh.close()
print('初始单词:',text)
print('数字密码:',get_key(text))
print('初始字母密码:',get_letter(text))
print('字母密码:',get_letter_(text))


初始单词: ['so', 'what', 'should', 'we', 'do', 'to', 'protect', 'our', 'identity', 'informatio', 'Keep', 'your', 'important', 'documents', 'properly', 'dont', 'tell', 'your', 'informatio', 'to', 'the', 'stranger', 'when', 'you', 'use', 'a', 'computer', 'please', 'make', 'sure', 'that', 'this', 'computer', 'has', 'firewall', 'if', 'you', 'sign', 'in', 'some', 'pplication', 'you', 'should', 'download', 'the', 'safe', 'pplication', 'the', 'related', 'department', 'should', 'devote', 'great', 'effects', 'to', 'educating', 'citizens', 'to', 'keep', 'them', 'from', 'being', 'in', 'trouble']
数字密码: ['3091691222', '3620577194', '1358626136', '9140563542', '5492783782', '8291509772', '7867273387', '2955683263', '5409390538', '55218025510', '3524556714', '1377027424', '1461556209', '4189206409', '1565021418', '9951063304', '3157593274', '8937076774', '11055471810', '8305239162', '9022103143', '1426874968', '5813392474', '1026621523', '8122391043', '3885573451', '5011381598', '2319940776', '6124393604', '5929021494', '3726434254', '9299014394', '9886633348', '7699941103', '3533723358', '6089308542', '7220334423', '4930618524', '5376649272', '8333645064', '59649766710', '2915502333', '9060310336', '4689967248', '4873495113', '3437968534', '53501381210', '5100023313', '5591866817', '51975978010', '1931427796', '8156252586', '5846146755', '2401610407', '9429580012', '1638924189', '9420669578', '4234768832', '5901075434', '5820934454', '8490748524', '6792234555', '2338924652', '8065326777']
初始字母密码: ['zt', 'znGu', 'anpwqf', 'zl', 'lu', 'wq', 'qrpwlcx', 'xxy', 'nlgnzjbc', 'nvhotnjxip', '9mjv', 'gpay', 'kpuxwzfuy', 'hsebqivuv', 'sspvnttb', 'mwpv', 'xhos', 'hwda', 'jwnpxnfyrp', 'us', 'yjk', 'uxvgrihx', 'fpmq', 'fwu', 'yyk', 'j', 'jxttwyez', 'urfgxj', 'ujon', 'ucyl', 'yqGu', 'bjnt', 'ituqacku', 'odz', 'ikwmycrt', 'll', 'hpb', 'tjmv', 'qq', 'asqe', 'wruojhzpuo', 'ctx', 'aptwtm', 'ktxqqshj', 'zqj', 'vgmi', 'yxnrleyqxo', 'xqi', 'ujshuld', 'lhsestumvu', 'wnvapi', 'fjeozh', 'kzhcz', 'fhneczb', 'bo', 'jivfialvp', 'gntphhvs', 'xx', 'smhy', 'yqkp', 'jzss', 'jfjsj', 'qo', 'vtvahme']
字母密码: ['uucpkntswl', 'anfxoqcwil', 'bnoyohdchm', 'xljkyorkan', 'iuhtsjlyua', 'vuudmxkgpi', 'wywahcbwat', 'rzxwzwcygp', 'ohhublyboh', 'lwfsaoibkp', '8hjykjsetd', 'dodvgdlsqc', 'kmquytjsym', 'hwluqkuwsa', 'wvsuhzmgbj', 'kopvukqvlq', 'blmtrsqenp', 'gvbzjldubd', 'pqmrzqfbnp', 'ysndakpjvm', 'wlgsmfrvqa', 'bzvdwogxta', 'ekmtvgprrp', 'ctudzfilsq', 'avearlbpcg', 'cnsrbjgdkf', 'ermtucirjw', 'xofeaeaqri', 'tgllfwlfhj', 'udvnltsyhu', 'whicaviuyw', 'ypouktsxqb', 'jrntuzhtuo', 'kfufnkeokr', 'niyixjrngt', 'ngrikmzghn', 'fsdkhwxrdu', 'zoiovwqvdi', 'rqfwkmabss', 'uqmncdplom', 'uypjeibnto', 'zozxroakci', 'vnwaqjutky', 'gtbqmqhjyy', 'zihhxrqhca', 'agfhknfyor', 'ytorejtnpo', 'cnekixwjur', 'ynngzmghft', 'leudwxoisu', 'biqcrdgujf', 'jhxrbmzdsc', 'ouefcablnz', 'nhijcbbkfd', 'xugcdnmwru', 'nlbicxjtps', 'jpulhjsxmn', 'zxivocisga', 'nikuthfyya', 'ujksifakhy', 'kusqvovtzh', 'fjorlwzjle', 'qtputmlfbc', 'arsciueuhe']

In [53]:
import random, string

for c in range(5):
    print(random.sample(string.ascii_letters, 8))


['t', 'r', 'l', 'k', 'b', 'B', 'G', 'N']
['d', 'Y', 'l', 'q', 'P', 'W', 'X', 'D']
['E', 'g', 'J', 'C', 'l', 'i', 'Q', 'r']
['r', 'M', 'j', 'U', 'v', 'i', 'L', 'l']
['d', 'w', 'M', 'W', 'm', 'A', 'i', 'f']