日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

古典密码习题解析

發布時間:2025/3/19 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 古典密码习题解析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.














2.20 代碼解題:

package mima_210;public class Main {public static void main(String[] args) {// TODO Auto-generated method stubString str="I thought to see the fairies in the"+ "fields,but I saw only th evil elephants"+ "with their black backs!Woe!how that"+ "sight awed me! The elves danced all"+"around and about while I heard voices"+"calling clearly.Ah! how I tried to"+"see-throw off the ugly clout-but no blind"+"eye of a mortal was permitted to spy"+"them.So then came minstrels,having gold"+"trumpets,harps and drums.These palyed"+"very loudly beside me,breaking that spell"+"So the dream vanished, whereat I thanked"+"Heaven.I shed many tears before the thin"+"straw.Now though the Enchanter gnash"+"Spring returns. Oh,wretched man!Hell"+"gapes, Erebus now lies open.The mouths"+"of Death wait on thy end.";String indexs="787656543432112343456567878878765654"+ "3432112343456567878878765654433211234";//首先對該字符串進行篩選,將空格標點去掉String newStr="";for(int t=0;t<str.length();t++){char c=str.charAt(t);if((c<='z'&&c>='a')||(c<='Z'&&c>='A')){newStr+=c;}}System.out.println("密鑰長度為:"+indexs.length()+"字符串長度為:"+newStr.length());//每五組一行的格式輸出整理好的字符串for(int i=0;i<indexs.length()-9;i++){if(i%6==0&&i!=0)System.out.println();for(int j=0;j<8;j++){System.out.print(newStr.charAt(j+i*8));}System.out.print(" ");}//輸出密文System.out.println();System.out.print("密文為:");for(int i=0;i<indexs.length()-9;i++){int j=indexs.charAt(i)-48;System.out.print(newStr.charAt(j+i*8-1));}} }

運行結果如下:

?

密鑰長度為:73字符串長度為:514

Ithought?? toseethe??fairiesi?? nthefiel?? dsbutIsa??wonlythe??

vileleph?? antswith??theirbla?? ckbacksW?? oehowtha??tsightaw??

edmeThee?? lvesdanc??edallaro?? undandab?? outwhile??Iheardvo??

icescall?? ingclear??lyAhhowI?? triedtos?? eethrowo??fftheugl??

ycloutbu?? tnoblind??eyeofamo?? rtalwasp?? ermitted??tospythe??

mSothenc?? ameminst??relshavi?? nggoldtr?? umpetsha??rpsanddr??

umsThese?? palyedve??ryloudly?? besideme?? breaking??thatspel??

lSothedr?? eamvanis??hedwhere?? atIthank? ?edHeaven??Ishedman??

ytearsbe?? forethet??hinstraw?? Nowthoug?? htheEnch??antergna??

shSpring?? returnsO??hwretche?? dmanHell?? gapesEre??busnowli??

esopenTh?? emouthso??fDeathwa?? itonthye??

密文為:hesittlseahselddweslodogunopeennhdtasylebtSmwIedstruhngOhlrwehtn

?

由于覺得個人手工來統計密文,會很容易出現失誤和偏差,所以將該過程編寫程序處理,編程過程中發現密鑰的長度較長,沒有足夠的字符串供密鑰使用,故認為該題目所給信息存在問題。但是,對于該加密解密方法可以認同。此外,為了編程處理簡便,將最后的兩個字母省略掉了。

?


與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的古典密码习题解析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。