日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

古典密码习题解析

發(fā)布時(shí)間:2025/3/19 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 古典密码习题解析 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.














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";//首先對該字符串進(jìn)行篩選,將空格標(biāo)點(diǎn)去掉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));}} }

運(yùn)行結(jié)果如下:

?

密鑰長度為: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

?

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

?


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

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。