有誰能告訴我這個密碼的名字嗎?有誰能告訴我這個密碼的名字嗎?
我知道這是一個簡單的替代密碼,我只是不知道它的名字。
密碼密鑰:
help
密碼字母:
文字:
this is a test
密文:
tdfs fs h tast
有誰能告訴我這個密碼的名字嗎?有誰能告訴我這個密碼的名字嗎?
我知道這是一個簡單的替代密碼,我只是不知道它的名字。
密碼密鑰:
help
密碼字母:
文字:
this is a test
密文:
tdfs fs h tast
是不是隻是一個簡單的substitution cipher?您剛剛將4個「幫助」字母移到前面,並將所有剩餘字母移到右側。
編輯
下面是Python作爲拉姆達,itertools,以及星號(*)的參數,並且浪費時間(也許是拯救這可能是對編碼在python密碼一個有趣的討論)練習的實現:
import string
from itertools import izip, count, starmap
def cipher(s,key):
# characters you want to translate, e.g.
# 'abcd ... xyz '
raw = string.ascii_lowercase + ' '
# cipher with your key, e.g.
# 'helpabcdfgi...z '
sub = key + string.translate(raw, None, key)
# create a dictionary from a character to an index
# in the original raw value string
m = dict(izip(raw, count()))
# looks up the index in the map using: starmap(m.get, s)
# then gets the substitution character: map(lambda i:sub[i], ...)
# and joins them together
return ''.join(map(lambda i:sub[i], starmap(m.get, s)))
和一些測試代碼來驗證它的工作原理:
ins = 'this is a test'
outs = cipher(ins, "help")
print ins,' -> ',outs
exp = "tdfs fs h tast"
if exp == outs:
print "pass :)"
else:
print "~~ FAIL ~~", " expected ", exp
輸出:
D:\temp>cipher.py
this is a test -> tdfs fs h tast
pass :)
是的,簡而言之,它只是一個簡單的替代密碼(我會說,是凱撒密碼的一種變體),但是因爲這使用了一個我想知道它是否真的有名字的密鑰。 – Chris
我想我找到了答案。凱撒變體,「混合字母」替代密碼。
簡單的是,但要加鐵道部的複雜性,你可以把它放在這樣的塊(成爲混合字母和多碼的混合物):
|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z
------------------------------------------------------
1|h|e|l|p|a|b|c|d|f|g|I|j|k|m|n|o|q|r|s|t|u|v|w|x|y|z
2|e|l|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v|w|x|y|z|h|e|l|p|a|b|c|d|f|g|I|j|k|m|n|o|q|r|s|t
22|v|w|x|y|z|h|e|l|p|a|b|c|d|f|g|I|j|k|m|n|o|q|r|s|t|u
23|w|x|y|z|h|e|l|p|a|b|c|d|f|g|I|j|k|m|n|o|q|r|s|t|u|v
24|x|y|z|h|e|l|p|a|b|c|d|f|g|I|j|k|m|n|o|q|r|s|t|u|v|w
25|y|z|h|e|l|p|a|b|c|d|f|g|I|j|k|m|n|o|q|r|s|t|u|v|w|x
26|z|h|e|l|p|a|b|c|d|f|g|I|j|k|m|n|o|q|r|s|t|u|v|w|x|y
這則更多的是V @ genere加密變形的,而比凱撒密碼變體。
用鑰匙還有:
help
同樣的消息:
this is a test
將成爲:
tfiv kx c hkep
了另一層複雜性將是組字母或者所有一起或成塊:
tfivkxchkep
或阻斷(3個字符):
tfi
vkx
chk
epz
With an extra z added to make up the missing character.
這個問題似乎是偏離主題,因爲它是有關加密和不包括規劃問題。 –
如果還沒有命名,我特此將其稱爲「Lucypher」。 –
我會說它是凱撒密碼的變體,但是凱撒密碼並不使用這樣的密鑰。 – Chris