词频分析题目及临时附件
This commit is contained in:
27
crypto/word_frequency_analysis/cipher.txt
Normal file
27
crypto/word_frequency_analysis/cipher.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
lkq pghiley veyyqh eom lkq nyea xi sqypfjq lf fzne
|
||||
|
||||
xo e gqeyj bqhfom fdg fso skqgq jfdolexoi skxirqgqm iqpgqli lf lkq gxvqgi eom lgqqi kdjjqm ydyyebxqi qvqgh mdiu lkqgq sei e veyyqh ikgfdmqm xo e gemxeol ayfs lkxi sei lkq pghiley veyyqh
|
||||
|
||||
lkq gqeifo nfg xli oejq sei pyqeg lf eoh seomqgqg skf kerrqoqm drfo lkxi jeaxpey ryepq lkq agfdom sei revqm sxlk aqjilfoqi lgqqi kem yqevqi fn qjqgeym eom nyfsqgi ikxjjqgqm sxlk ierrkxgq rqleyi lkq gxvqg nyfsqm sxlk e iqgqoq ixyvqgh yxakl xyydjxoelxoa lkq qolxgq veyyqh
|
||||
|
||||
bdl lkq jfil jeaoxnxpqol ixakl sei el lkq pqolqg fn lkq veyyqh e lgqq ageomqg lkeo eoh flkqg sxlk bgeopkqi ilgqlpkxoa fdl sxmq lfdpkxoa lkq iuxqi lkxi sei lkq pghiley lgqq xli begu jemq fn mxejfom eom xli ngdxl e pghiley erryq kqym lkq pfjbxoqm sximfj fn lkq sfgym
|
||||
|
||||
yqaqom lfym fn xli jeaxp skfqvqg leilqm lkq erryq sfdym aexo e mqqr domqgileomxoa fn lkq doxvqgiq bdl el e rgxpq lkq lgqq sfdym foyh bqeg foq ngdxl qvqgh pqoldgh eom fopq rxpuqm lkq veyyqh sfdym bq ikgfdmqm xo meguoqii nfg lkq oqzl kdomgqm hqegi
|
||||
|
||||
foq meh e hfdoa axgy oejqm qyege adxmqm bh lkq skxirqgi fn lkq sxom nfdom kqg seh lf lkq pghiley veyyqh jqijqgxcqm bh lkq bqedlh ikq sei lqjrlqm bh lkq yqaqom fn lkq pghiley lgqq ei ikq errgfepkqm xl lkq lgqq irfuq iqquqg fn sximfj mf hfd sxik lf pyexj lkq pghiley erryq”
|
||||
|
||||
“x mf” qyege gqryxqm kqg vfxpq lgqjbyxoa bdl x nqeg lkq meguoqii xl sfdym bgxoa
|
||||
|
||||
lkq lgqq gqirfomqm lkq meguoqii xi e pfoiqwdqopq bdl ofl e rdoxikjqol qvqgh yxakl peili e ikemfs sximfj bgxoai sxlk xl lkq bdgmqo fn uofsxoa
|
||||
|
||||
aelkqgxoa kqg pfdgeaq qyege pkfiq ofl lf leuq lkq erryq xoilqem ikq mqpxmqm lf ixl bqoqelk lkq lgqq yqllxoa xli ikxjjqgxoa yxakl meopq egfdom kqg mehi ldgoqm xolf oxakli eom oxakli xolf mehi sxlk qepk reiixoa jfjqol qyege nqyl e pfooqplxfo lf lkq sfgym egfdom kqg domqgileomxoa xl xo sehi ikq oqvqg xjeaxoqm
|
||||
|
||||
foq jfgoxoa ei lkq nxgil gehi fn meso uxiiqm lkq veyyqh lkq pghiley lgqq bfgq e oqs ngdxl xl sei of yfoaqg e pghiley erryq bdl e gemxeol kqegl ikxjjqgxoa sxlk pfyfgi lkel kem oqvqg bqqo iqqo bqnfgq
|
||||
|
||||
hfdg kqegl eom hfdg pkfxpq kevq lgeoinfgjqm lkq axnl skxirqgqm lkq lgqq sxlk yfvq eom relxqopq hfd kevq nfdom sximfj lkq kqegl kfymi lkq bqedlh fn domqgileomxoa sxlkfdl peilxoa e ikemfs
|
||||
|
||||
qyege sxlk lqegi fn tfh kqym lkq kqegl pyfiq ikq gqeyxcqm lkel ifjqlxjqi sximfj xio’l ebfdl leuxoa bdl ebfdl axvxoa ofl ebfdl uofsxoa qvqghlkxoa bdl domqgileomxoa lkq veydq fn qvqghlkxoa
|
||||
|
||||
eom if lkq yqaqom fn lkq pghiley veyyqh qvfyvqm lqyyxoa leyqi ofl fn e pghiley erryq bdl fn e gemxeol kqegl eom e hfdoa axgy skf pkfiq lf domqgileom lkq sfgym sxlk yfvq
|
||||
|
||||
lkq veyyqh pfolxodqm lf ayfs bgxaklqg lkeo qvqg sqypfjxoa seomqgqgi sxlk xli aqolyq qjbgepq eom gqjxomxoa lkqj lkel ifjqlxjqi lkq tfdgoqh eom lkq pkfxpqi jemq eyfoa lkq seh egq jfgq gqsegmxoa lkeo lkq mqilxoelxfo xliqyn
|
27
crypto/word_frequency_analysis/plaintext.txt
Normal file
27
crypto/word_frequency_analysis/plaintext.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
the crystal valley and the flag is welcome to oxfa
|
||||
|
||||
in a realm beyond our own where mountains whispered secrets to the rivers and trees hummed lullabies every dusk there was a valley shrouded in a radiant glow this was the crystal valley
|
||||
|
||||
the reason for its name was clear to any wanderer who happened upon this magical place the ground was paved with gemstones trees had leaves of emerald and flowers shimmered with sapphire petals the river flowed with a serene silvery light illuminating the entire valley
|
||||
|
||||
but the most magnificent sight was at the center of the valley a tree grander than any other with branches stretching out wide touching the skies this was the crystal tree its bark made of diamond and its fruit a crystal apple held the combined wisdom of the world
|
||||
|
||||
legend told of its magic whoever tasted the apple would gain a deep understanding of the universe but at a price the tree would only bear one fruit every century and once picked the valley would be shrouded in darkness for the next hundred years
|
||||
|
||||
one day a young girl named elara guided by the whispers of the wind found her way to the crystal valley mesmerized by the beauty she was tempted by the legend of the crystal tree as she approached it the tree spoke seeker of wisdom do you wish to claim the crystal apple”
|
||||
|
||||
“i do” elara replied her voice trembling but i fear the darkness it would bring
|
||||
|
||||
the tree responded the darkness is a consequence but not a punishment every light casts a shadow wisdom brings with it the burden of knowing
|
||||
|
||||
gathering her courage elara chose not to take the apple instead she decided to sit beneath the tree letting its shimmering light dance around her days turned into nights and nights into days with each passing moment elara felt a connection to the world around her understanding it in ways she never imagined
|
||||
|
||||
one morning as the first rays of dawn kissed the valley the crystal tree bore a new fruit it was no longer a crystal apple but a radiant heart shimmering with colors that had never been seen before
|
||||
|
||||
your heart and your choice have transformed the gift whispered the tree with love and patience you have found wisdom the heart holds the beauty of understanding without casting a shadow
|
||||
|
||||
elara with tears of joy held the heart close she realized that sometimes wisdom isn’t about taking but about giving not about knowing everything but understanding the value of everything
|
||||
|
||||
and so the legend of the crystal valley evolved telling tales not of a crystal apple but of a radiant heart and a young girl who chose to understand the world with love
|
||||
|
||||
the valley continued to glow brighter than ever welcoming wanderers with its gentle embrace and reminding them that sometimes the journey and the choices made along the way are more rewarding than the destination itself
|
31
crypto/word_frequency_analysis/wfa.py
Normal file
31
crypto/word_frequency_analysis/wfa.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import string
|
||||
import random
|
||||
|
||||
def generate_substitution_table():
|
||||
"""生成一个随机的单表替换表"""
|
||||
chars = list(string.ascii_lowercase) # 仅使用小写字母
|
||||
shuffled_chars = chars.copy()
|
||||
random.shuffle(shuffled_chars)
|
||||
return dict(zip(chars, shuffled_chars))
|
||||
|
||||
def substitute_with_table(s, table):
|
||||
"""使用提供的替换表对字符串进行替换"""
|
||||
return ''.join(table[char] if char in table else char for char in s)
|
||||
|
||||
def process_file_for_substitution(input_file, output_file):
|
||||
with open(input_file, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
substitution_table = generate_substitution_table()
|
||||
substituted_content = substitute_with_table(content, substitution_table)
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
f.write(substituted_content)
|
||||
return substitution_table
|
||||
|
||||
|
||||
|
||||
# 使用函数
|
||||
input_file = "plaintext.txt"
|
||||
output_file = "cipher.txt"
|
||||
process_file_for_substitution(input_file, output_file)
|
Reference in New Issue
Block a user