<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Simple Columnar Transposition Technique(簡單分欄式變換加密技術(shù))

    簡單分欄式變換加密技術(shù):
    ? (1)將明文消息一行一行寫入預定長度的矩形中
    ? (2)一列一列讀消息,但不一定按1、2、3列的順序,也可以按隨機順序,如2、3、1
    ? (3)得到的消息就是密文消息
    ? 注:密鑰為字符的話,就根據(jù)ASII碼的大小進行組合。
    ? 實現(xiàn)的算法:按照排序好的數(shù)組bufClone的字符遍歷尋找對應buf的字符的位置,然
    ? 后取出該位置整數(shù)倍的位置的字符
    ? SimpleColumar.java
    ?1?package?SimpleColumnarTransposition;
    ?2?import?javax.swing.JFrame;
    ?3?public?class?SimpleColumar?{
    ?4?????public?static?void?main(String[]?args)?{
    ?5?????????//實例化一個窗體
    ?6?????????SimpleColumnarFrame?frame?=?new?SimpleColumnarFrame();
    ?7?????????frame.setVisible(true);
    ?8?????????frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ?9?????}????
    10?}
    11?
    12?

    ? SimpleColumnarFrame.java
    ??1?package?SimpleColumnarTransposition;
    ??2?
    ??3?import?java.awt.event.ActionEvent;
    ??4?import?java.awt.event.ActionListener;
    ??5?import?java.util.Arrays;
    ??6?
    ??7?import?javax.swing.*;
    ??8?
    ??9?@SuppressWarnings({?"static-access",?"static-access",?"static-access",?"static-access"?})
    ?10?public?class?SimpleColumnarFrame?extends?JFrame?{
    ?11?????JButton?btnKey?=?new?JButton();
    ?12?????JButton?btnReset?=?new?JButton();
    ?13?????JLabel?lbTest?=?new?JLabel();
    ?14?????JLabel?lbKey?=?new?JLabel();
    ?15?????JPasswordField?jpf?=?new?JPasswordField();
    ?16?????JTextField?tfDarkPass?=?new?JTextField();
    ?17?????JTextField?tfKey?=?new?JTextField();
    ?18?????char[]?arr;
    ?19?????byte[]?buf,bufClone;
    ?20?????
    ?21?????public?SimpleColumnarFrame()?{
    ?22?????????this.setSize(300,200);????????//設置窗體大小
    ?23?????????this.setTitle("簡單變換柵欄加密法");
    ?24?????????this.setResizable(false);????//設置窗體大小不可變
    ?25?????????Init();????????//填充窗體內(nèi)容
    ?26?????}
    ?27?????
    ?28?????
    ?29?????private?void?makeBrightText()?{
    ?30?????????tfDarkPass.setEditable(true);
    ?31?????????arr?=?jpf.getPassword();?????//獲取明文
    ?32?????????buf?=?tfKey.getText().getBytes();?????//獲取密鑰,用ASII碼進行比較
    ?33?????????bufClone?=?buf.clone();?????//克隆數(shù)組
    ?34?????????Arrays.sort(bufClone);?????????//?根據(jù)ASII碼排序
    ?35?????????reform();????????//重組字符
    ?36?????????tfDarkPass.setEditable(false);
    ?37?????}
    ?38?????
    ?39?????private??void?reform()?{
    ?40?????????/*?按照排序好的數(shù)組bufClone的字符遍歷尋找對應buf的字符的位置,然
    ?41????????????后取出該位置整數(shù)倍的位置的字符*/
    ?42?????????char[]?a?=?new?char[arr.length];
    ?43?????????int?index?=?0;
    ?44?????????for(int?i=0;i<bufClone.length;i++)
    ?45?????????????for(int?j=0;j<buf.length;j++)?
    ?46?????????????????if(buf[j]==bufClone[i])?
    ?47?????????????????????for(int?k=0;k<arr.length;k++)?
    ?48?????????????????????????if((k+1)%buf.length==(j+1)%buf.length)
    ?49?????????????????????????????a[index++]?=?arr[k];????????
    ?50?????????String?str?=?new?String(a);
    ?51?????????tfDarkPass.setText(str);
    ?52?????}
    ?53?????
    ?54?????private?void?reset()?{
    ?55?????????tfDarkPass.setEditable(true);
    ?56?????????jpf.setText("");
    ?57?????????tfKey.setText("");
    ?58?????????tfDarkPass.setText("");
    ?59?????????tfDarkPass.setEditable(false);
    ?60?????}
    ?61?
    ?62?????private?void?Init()?{
    ?63?????????//????設置窗體內(nèi)容????????
    ?64?????????this.setLayout(null);
    ?65?????????lbTest.setText("輸入明文:");?
    ?66?????????lbTest.setBounds(30,?20,?80,?30);
    ?67?????????lbKey.setText("密鑰:?");
    ?68?????????lbKey.setBounds(30,?70,?80,?30);
    ?69?????????btnKey.setText("生成密文:");
    ?70?????????btnKey.setBounds(75,?110,?100,?30);????
    ?71?????????btnReset.setText("重置");
    ?72?????????btnReset.setBounds(5,?110,?60,?30);????
    ?73?????????jpf.setBounds(160,?20,?80,?30);
    ?74?????????jpf.setEchoChar('*');????????
    ?75?????????tfDarkPass.setBounds(190,?110,?80,?30);
    ?76?????????tfDarkPass.setEditable(false);
    ?77?????????tfKey.setBounds(160,?70,?80,?30);
    ?78?????????
    ?79?????????this.add(lbTest);
    ?80?????????this.add(jpf);
    ?81?????????this.add(lbKey);
    ?82?????????this.add(btnKey);
    ?83?????????this.add(btnReset);
    ?84?????????this.add(tfDarkPass);
    ?85?????????this.add(tfKey);
    ?86?????????
    ?87?????????btnKey.addActionListener(new?ActionListener(){
    ?88?????????????//觸發(fā)事件,生成明文
    ?89?????????????public?void?actionPerformed(ActionEvent?e)?{
    ?90?????????????????makeBrightText();????????????
    ?91?????????????}
    ?92?
    ?93?????????});
    ?94?????????
    ?95?????????btnReset.addActionListener(new?ActionListener(){
    ?96?????????????//觸發(fā)事件,生成明文
    ?97?????????????public?void?actionPerformed(ActionEvent?e)?{
    ?98?????????????????reset();????//????重置????
    ?99?????????????}
    100?
    101?????????});
    102?????}
    103?????
    104?}
    105?

    ?現(xiàn)實圖解:
    ?SimpleColumar.jpg
    ?輸入明文及密鑰,點擊生成密文按鈕,則產(chǎn)生相應密文,重置,則重新填寫相關(guān)信息。
    ?

    posted on 2008-09-08 11:57 nonels 閱讀(820) 評論(0)  編輯  收藏 所屬分類: J2SE

    <2008年9月>
    31123456
    78910111213
    14151617181920
    21222324252627
    2829301234
    567891011

    導航

    統(tǒng)計

    常用鏈接

    留言簿(2)

    隨筆分類(16)

    隨筆檔案(16)

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 色噜噜亚洲精品中文字幕| 成人免费福利视频| 亚洲精品人成无码中文毛片| 日韩一区二区a片免费观看 | 亚洲日产2021三区在线| 亚洲欧美日韩久久精品| 日韩精品视频免费网址| 亚洲国产精品婷婷久久| 美女内射无套日韩免费播放| 亚洲国产电影av在线网址| 免费中文字幕视频| 国产成人yy免费视频| 精品丝袜国产自在线拍亚洲| 天天操夜夜操免费视频| 国产精品亚洲а∨无码播放不卡| 精品无码人妻一区二区免费蜜桃| 亚洲一区综合在线播放| 国产成人无码免费看视频软件| 亚洲精品第一综合99久久| 免费中文字幕一级毛片| 一区二区亚洲精品精华液| 国产免费拔擦拔擦8x| 一区二区三区免费精品视频| 国产精品免费视频网站| 免费手机在线看片| 婷婷久久久亚洲欧洲日产国码AV| 72pao国产成视频永久免费| 亚洲AV无码国产精品色午友在线| a一级爱做片免费| 久久精品国产亚洲AV网站| 波多野结衣免费在线| 特级毛片全部免费播放a一级| 国产片免费在线观看| 中国国产高清免费av片| 亚洲AV无码乱码在线观看代蜜桃 | 无人在线观看完整免费版视频 | 亚洲国产精品久久久久| 成年在线观看网站免费| 好猛好深好爽好硬免费视频| 亚洲午夜福利精品久久 | 精品亚洲成a人片在线观看|