摘要:隨機字符串導(dǎo)入模塊自動導(dǎo)入模塊輸出所有字母大小寫和數(shù)字自動導(dǎo)入模塊愷撒加密每個英文字母替換為字母表第個字母舊的新的對原有小寫字母向右移動位用于創(chuàng)建字符串映射的轉(zhuǎn)換表,這里生成的是一個字典舊的新的根據(jù)轉(zhuǎn)換表去轉(zhuǎn)換對應(yīng)字符暴力破解對原有小寫字母
隨機字符串
導(dǎo)入string模塊
ctrl+enter :自動導(dǎo)入模塊
import string import random get_code = string.ascii_letters +string.digits #輸出所有字母(大小寫)和數(shù)字 print(get_code) #ctrl+enter :自動導(dǎo)入模塊愷撒加密
每個英文字母替換為字母表第k個字母
text = "hello"
next = "khoor"
print(string.ascii_letters) #舊的:abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ #新的:defghijklmnopqrstuvwxyzabc DEFGHIJKLMNOPQRSTUVWXYZABC def kaisa(text="hello",k=3): #對原有小寫字母向右移動k位 lower = string.ascii_lowercase[k:]+string.ascii_lowercase[:k] upper = string.ascii_uppercase[k:]+string.ascii_uppercase[:k] #用于創(chuàng)建字符串映射的轉(zhuǎn)換表,這里生成的table是一個字典{舊的ascii:新的ascii} table = str.maketrans(string.ascii_letters,lower+upper) #根據(jù)轉(zhuǎn)換表去轉(zhuǎn)換對應(yīng)字符 return text.translate(table) crypt = kaisa() print(crypt) khoor暴力破解
import string def kaisa(text="hello",k=3): #對原有小寫字母向右移動k位 lower = string.ascii_lowercase[k:]+string.ascii_lowercase[:k] upper = string.ascii_uppercase[k:]+string.ascii_uppercase[:k] #用于創(chuàng)建字符串映射的轉(zhuǎn)換表,這里生成的table是一個字典{舊的ascii:新的ascii} table = str.maketrans(string.ascii_letters,lower+upper) #根據(jù)轉(zhuǎn)換表去轉(zhuǎn)換對應(yīng)字符 return text.translate(table) def check(text): """ 思路:測試文本中是否存在至少兩個最常見的英文單詞,如果有,則代表破解成功 """ mostcommands =("is","and","have","to","not") #[1 for word in mostcommands if word in text] #遍歷mostcommand,如果這個單詞在破解后的文本里,列表添加‘1’ return len([1 for word in mostcommands if word in text])>2 def bruteforce(text): for i in range(26): #所有可能的偏移值,一次次調(diào)用kaisa(),直到check()返回值True t = kaisa(text,-i) #往左移,開始破解 if check(t): #如果滿足check返回值是True print(i) print(t) break text="If not to the sun for smiling, warm is still in the sun there, but wewill laugh more confident calm; if turned to found his own shadow, appropriate escape, the sun will be through the heart,warm each place behind the corner; if an outstretched palm cannot fall butterfly, then clenched waving arms, given power; if I can"t have bright smile, it will face to the sunshine, and sunshine smile together, in full bloom." cryptstr = kaisa(text=text,k=10) print(cryptstr) bruteforce(cryptstr) Sp xyd dy dro cex pyb cwsvsxq, gkbw sc cdsvv sx dro cex drobo, led gogsvv vkeqr wybo myxpsnoxd mkvw; sp debxon dy pyexn rsc ygx crknyg, kzzbyzbskdo ocmkzo, dro cex gsvv lo drbyeqr dro rokbd,gkbw okmr zvkmo lorsxn dro mybxob; sp kx yedcdbodmron zkvw mkxxyd pkvv leddobpvi, drox mvoxmron gkfsxq kbwc, qsfox zygob; sp S mkx"d rkfo lbsqrd cwsvo, sd gsvv pkmo dy dro cexcrsxo, kxn cexcrsxo cwsvo dyqodrob, sx pevv lvyyw. 10 If not to the sun for smiling, warm is still in the sun there, but wewill laugh more confident calm; if turned to found his own shadow, appropriate escape, the sun will be through the heart,warm each place behind the corner; if an outstretched palm cannot fall butterfly, then clenched waving arms, given power; if I can"t have bright smile, it will face to the sunshine, and sunshine smile together, in full bloom.
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/42247.html
摘要:語言中使用斜杠來表示一個字符串的結(jié)束。注意事項由于被替換,如果字符串末尾有,換行會出現(xiàn)兩次。函數(shù)的原型成功返回失敗返回將的字符串錄入到文件指針中。 前言: 考慮到之前在專欄中講字符串的時候有些知識點沒有詳細地講解,所以本篇是對字符串相關(guān)的知識點的補充篇!例如 %s 輸出左對齊右對齊,限制...
摘要:容器的類圖如下圖所示接口定義了存取一組對象的方法其子接口和分別定義了存儲方式。中的數(shù)據(jù)對象沒有順序且不可以重復(fù)。注意相等的對象應(yīng)該具有相等的 Chap 6 常用類 focus on : 字符串相關(guān)類 (String, StringBuffer) 基本數(shù)據(jù)類型包裝類 Math類 File類 枚舉類 6.1 字符串相關(guān)類 String 類 -- java.lang.String 類...
摘要:在市面上找到一個好用的樹形穿梭框組件都很難,又不想僅僅因為一個穿梭框在之外引入其他重量級插件,因此就有了。版本增加穿梭框左側(cè)右側(cè)數(shù)據(jù)勾選事件,穿梭框左側(cè)右側(cè)底部。 el-tree-transfer 簡介·請先閱讀文檔及版本說明 因為公司業(yè)務(wù)使用vue框架,ui庫使用的element-ui。在市面上找到一個好用的vue樹形穿梭框組件都很難,又不想僅僅因為一個穿梭框在element-ui之...
摘要:聲明以下記錄了本人實驗性地探索過程,不代表正確,請謹(jǐn)慎食用。取消注釋,并添加兩個屬性,。由于在中被設(shè)置成了的,所以并不適合加密存入。算法碰撞的可能性很小,因此基本可以保證和加密后都是獨一無二的,防止黑客用彩虹表爆表。 聲明:以下記錄了本人實驗性地探索過程,不代表正確,請謹(jǐn)慎食用。也歡迎提出各種批評建議,幫助我改正錯誤。謝謝! 1.注冊 注冊時在注冊的jsp頁面使用js函數(shù)進行合法性驗證...
摘要:二和之間的不同和都是的字符編碼方式。提示如果你喜歡閱讀關(guān)于的內(nèi)部字符編碼,可以,這里更詳細解釋了實際的問題,以及提供了解決方法。 對于 JavaScript 使用的是 UCS-2 還是 UTF-16 這個問題,我找了很久,沒有發(fā)現(xiàn)一個權(quán)威的回答,我決定自己研究一下它。這個回答來自于你對 JavaScript 引擎或者對 JavaScript 語言的理解。 一、著名的 BMP(Basic...
閱讀 1557·2023-04-25 18:56
閱讀 1501·2021-09-29 09:34
閱讀 1722·2021-09-22 15:51
閱讀 3523·2021-09-14 18:03
閱讀 1176·2021-07-23 17:54
閱讀 2034·2019-08-29 18:38
閱讀 2915·2019-08-29 12:38
閱讀 623·2019-08-26 13:41