亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 187-211.html

?? 這個是密碼學的經(jīng)典著作
?? HTML
?? 第 1 頁 / 共 3 頁
字號:
<html><head><TITLE>Learn Encryption Techniques with BASIC and C++:Transposition-based Monoalphabetic Substitution</TITLE>
<!-- BEGIN HEADER --><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><SCRIPT><!--function displayWindow(url, width, height) {        var Win = window.open(url,"displayWindow",'width=' + width +',height=' + height + ',resizable=1,scrollbars=yes');}//--></SCRIPT></HEAD><body bgcolor="ffffff" link="#006666" alink="#006666" vlink="#006666"><P>
<CENTER><B>Learn Encryption Techniques with BASIC and C++</B>
<FONT SIZE="-2">
<BR>
<I>(Publisher: Wordware Publishing, Inc.)</I>
<BR>
Author(s): Gil Held
<BR>
ISBN: 1556225989
<BR>
Publication Date: 10/01/98
</FONT></CENTER>
<P>


<!-- Empty Reference Subhead -->

<!--ISBN=1556225989//-->
<!--TITLE=Learn Encryption Techniques with BASIC and C++//-->
<!--AUTHOR=Gilbert Held//-->
<!--PUBLISHER=Wordware Publishing, Inc.//-->
<!--CHAPTER=4//-->
<!--PAGES=187-211//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="184-187.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="211-215.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="CENTER"><A NAME="Heading19"></A><FONT COLOR="#000077">The CIPHER6.CPP Program</FONT></H4>
<P>Continuing our presentation of C&#43;&#43; versions of each BASIC language version, Listing 4.7 contains the program listing of CIPHER6.CPP. As you review the program listing, you will note that an extensive effort was made to make the program as &#147;crash-free&#148; as possible, as well as to incorporate the functionality of the BASIC language version of the program. When you examine the program listing, you may wish to focus your attention upon the functions interval, which creates the cipher stream based on interval extraction, and numericExtraction, which creates the cipher stream used to encrypt files by pulling off the columns from the matrix in alphabetical order based on the character in the top row and inserting them into the cipher array. Although many of the previously developed C&#43;&#43; functions are included once again in this program listing, the listing is presented in its entirety to facilitate reference to the relationship between functions as well as the manner by which they operate.
</P>
<P><B>Listing 4.7</B> The CIPHER6.CPP program listing.</P>
<!-- CODE //-->
<PRE>
/*
cipher6.cpp
C&#43;&#43; code written by Jonathan Held using Microsoft Visual C&#43;&#43;,
version 5.0, on March 24, 1998.
*/

//standard include files
#include&lt;iostream.h&gt;
#include&lt;assert.h&gt;
#include&lt;string.h&gt;
#include&lt;ctype.h&gt;
#include&lt;fstream.h&gt;

//function prototypes
bool checkInput(char * &#38;);
void createCipherStream(char *, char[]);
void createMatrix(char ** &#38;, const char [], const int, const int);
void display(char *);
bool encryptText(char *, char *, const char [], const char[], char []);
void deleteMatrix(char **&#38;, const int, const int);
int findLowestValue(int *&#38;, const int);
void formatData(char []);
char* formCipheredMessage(const char[], const char [], char []);
void getFileNames(char *&#38;, char *&#38;);
int getInputType(void);
int getKeyword(char *&#38;);
bool getMessage(char*, char*, char [], const char[], const char[]);
void getShiftKey(char &#38;);
void groupBUFFER(ofstream, int);
void interval(char[]);
void numericExtraction(char **&#38;, char [], const int, const int);
void printCipherToFile(ofstream, char[]);
void printMatrix(char ** &#38;, const int, const int);
void reviseCipherStream(char **&#38;, char [], const int, const int,
                           const int);
void shiftKeyword(char [], const char);
void simpleExtraction(char **&#38;, char [], const int, const int);
int welcome(void);

//constants we will use
const int ONE = 1, TWO = 2, THREE = 3, FIVE = 5, TWENTYFIVE = 25,
      TWENTYSIX = 26, TWENTYSEVEN = 27, SIXTYFIVE = 65,
      NINETY = 90, NINETYTWO = 92, SIZE = 256, DUMMY_VAL = 999,
      BIGSIZE = 1000;
char BUFFER[BIGSIZE] = &#123;'\0'&#125;;
//----------------------------------------------------------------
//Function: main()
//Parameters: None
//Return Type: int - 0 execution is normal, 1 abnormal termination
//Purpose: Runs the main part of the program.
//----------------------------------------------------------------
int main()
&#123;
 char plaintext[TWENTYSEVEN] = &#123;'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', '\0'&#125;;

 char cipherStream[TWENTYSEVEN] = &#123;'\0'&#125;;
 char message_to_cipher[SIZE], enciphered_message[SIZE];

 char ** cMatrix;
 char *keyword, key, *infile, *outfile;
 int rows, columns, input_type, encipher_type;
 bool success;


 encipher_type = welcome();

 if(encipher_type == ONE)&#123;
    getKeyword(keyword);
    createCipherStream(keyword, cipherStream);
    cout &lt;&lt; "Keyword-based alphabet is: "
         &lt;&lt; cipherStream &lt;&lt; endl &lt;&lt; endl;
    interval(cipherStream);
 &#125;
 else &#123;
   //get the keyword we are going to use, determine number of rows
   //and columns of our matrix
   columns = getKeyword(keyword);
   rows = TWENTYSIX/columns;

   //integer division requires that we check and see if there is a
   //remainder; if so, we need to add one extra row to our matrix
   if(TWENTYSIX%columns)&#123;
     rows&#43;&#43;;
   &#125;

   //create the initial ciphertext stream
   createCipherStream(keyword, cipherStream);

   //echo to the user what we have
   cout &lt;&lt; "Plaintext-based alphabet is: " &lt;&lt; plaintext &lt;&lt; endl
        &lt;&lt; "Keyword-based alphabet is:   " &lt;&lt; cipherStream &lt;&lt; endl
                       &lt;&lt; endl;

   //insert the stream into our matrix
   createMatrix(cMatrix, cipherStream, rows, columns);

   reviseCipherStream(cMatrix, cipherStream, rows, columns,
                   encipher_type);

 &#125;

 getShiftKey(key);
 shiftKeyword(cipherStream, key);

 getFileNames(infile, outfile);

 input_type = getInputType();

 //process file input
 if(input_type)&#123;
   success = encryptText(infile, outfile, plaintext, cipherStream,
                 enciphered_message);
 &#125;
 else &#123;
   cout &lt;&lt; "Use a \'/\' to leave a line in plaintext." &lt;&lt; endl
     &lt;&lt; "Use a \'\\' to indicate end of message input. " &lt;&lt; endl;
   success = getMessage(infile, outfile, message_to_cipher, plaintext,
    cipherStream);
 &#125;

 //report success of operation
 if(!success)&#123;
   cerr &lt;&lt; "Error: Invalid filename specified. Goodbye." &lt;&lt; endl;
 &#125;
 else &#123;
   cout &lt;&lt; "Press return to display resulting enciphered message."
                    &lt;&lt; endl;
   //get the newlines off the current input stream
   cin.get();
   if(input_type == ONE)&#123;
     cin.get();
   &#125;
   display(outfile);
 &#125;

 //delete dynamically allocated memory accordingly
 if(encipher_type != ONE)
   deleteMatrix(cMatrix, rows, columns);

 delete [] infile;
 delete [] outfile;
 delete [] keyword;

 return (!success);
&#125;//end main()


//----------------------------------------------------------------
//Function: checkInput()
//Parameters: input - the keyword the user entered
//Return Type: bool - true if the input string contains an error,
//       false otherwise
//Purpose: Checks the user's keyword for invalid characters.
//----------------------------------------------------------------
bool checkInput(char * &#38;input)
&#123;
 bool error = false;
 int count = strlen(input);

 for(int ix=0; ix&lt;count; ix&#43;&#43;)&#123;

   int char_value = static_cast&lt;int&gt;(*(input&#43;ix));
   //determine if the user did not enter an uppercase character
   if((char_value &lt; SIXTYFIVE) || (char_value &gt; NINETY))&#123;
     error = true;
     cerr &lt;&lt; "You entered an invalid keyword!" &lt;&lt; endl &lt;&lt; endl;
     break;
   &#125;
 &#125;

 if(count == 0)&#123;
   cerr &lt;&lt; "You entered an invalid keyword!" &lt;&lt; endl &lt;&lt; endl;
   error = true;
 &#125;

 return error;
&#125;//end checkInput()


//----------------------------------------------------------------
//Function: createCipherStream()
//Parameters: input - the keyword the user entered
//      cipher - the keyword alphabet that will be constructed
//Return Type: None
//Purpose: Creates a preliminary cipher stream that will be used to
//form the cipher matrix.
//----------------------------------------------------------------
void createCipherStream(char *input, char stream[])
&#123;
 bool used[TWENTYSIX];
 int index = 0,
   count = strlen(input);

 //no characters are initially used
 for(int ix=0; ix&lt;TWENTYSIX; ix&#43;&#43;)&#123;
   used[ix] = false;
 &#125;

 //keep track of each character used, start forming the keyword
 //alphabet
 for(int jx=0; jx&lt;count; jx&#43;&#43;)&#123;

   //get each character of the input string (integer value)
   int char_value = static_cast&lt;int&gt;(*(input&#43;jx));

   if(used[char_value-SIXTYFIVE])&#123;
     //do nothing - the character was already used
   &#125;
   else &#123;
     //mark as used and add to the keyword alphabet
     used[char_value-SIXTYFIVE] = true;
     *(stream&#43;index&#43;&#43;) = static_cast&lt;char&gt;(char_value);
   &#125;
 &#125;

 //go through the list of characters used - those which weren't
 //used should be added to the keyword alphabet
 for(int kx=0; kx&lt;TWENTYSIX; kx&#43;&#43;)&#123;

   if(!(used[kx]))&#123;
     *(stream&#43;index&#43;&#43;) = static_cast&lt;char&gt;(SIXTYFIVE&#43;kx);
   &#125;
 &#125;

 return;
&#125;//end createCipherStream()


//----------------------------------------------------------------
//Function: createMatrix()
//Parameters: matrix - the matrix we are going to create
//      CSTREAM - the initial cipher stream based on the
//          user's keyword
//      ROWS - the number of rows in the matrix
//      COLS - the number of columns in the matrix
//Return Type: None
//Purpose: Creates a numeric key transposed matrix, identical to
//figure 4.4.
//----------------------------------------------------------------
void createMatrix(char ** &#38;matrix, const char CSTREAM[], const int ROWS,
                    const int COLS)
&#123;
 int count = 0;

 //dynamically allocate memory for the RxC matrix
 //we use assert to ensure that memory was allocated;
 //if not, then the program will terminate abnormally
  assert(matrix = new char*[ROWS]);
  for(int ix=0; ix&lt;ROWS; ix&#43;&#43;)&#123;
    *(matrix &#43; ix) = new char[COLS];
  &#125;

  //fill in the matrix
  for(int jx=0; jx&lt;ROWS; jx&#43;&#43;)&#123;
    for (int kx=0; kx&lt;COLS; kx&#43;&#43;)&#123;
    //we only want to enter a character into the matrix
    //twenty-six times - most of the time we allocate
    //a matrix larger than what we will need to use; when
    //we have more than 26 characters, we simply insert a
    //null terminator into the matrix
      if(count &lt; TWENTYSIX)
        *(*(matrix&#43;jx)&#43;kx) = CSTREAM[count&#43;&#43;];
            else
        *(*(matrix&#43;jx)&#43;kx) = '\0';
    &#125;
 &#125;

 return;
&#125;//end createMatrix()


//----------------------------------------------------------------
//Function: encryptText()
//Parameters:  inp_file - the name of the input plaintext file
//       outp_file - the name of the output ciphertext file
//       PTEXT[] - the plaintext alphabet
//       CTEXT[] - the ciphertext alphabet
//       encoded_msg[] - the message to be encoded
//Return Type: bool, indicating success of operation
//Purpose: Used to encrypt file input.  Takes each line of the input
//file, encrypts it, and saves the result to the specified output
//file.
//----------------------------------------------------------------
bool encryptText(char * inp_file, char * outp_file, const char PTEXT[],
          const char CTEXT[], char encoded_msg[])
&#123;
 bool success = false;
 char ip[SIZE];

 //declare file stream objects
 ifstream input(inp_file, ios::in);
 ofstream output(outp_file, ios::app);

 if((!input) || (!output))&#123;
   //do nothing - I/O error; user will be notified upon
   //procedure's return to main()
 &#125;
 else &#123;

   success = true;

   //print plaintext and ciphertext alphabets to the
   //output file
   output &lt;&lt; "PLAINTEXT:  " &lt;&lt; PTEXT &lt;&lt; endl;
   output &lt;&lt; "CIPHERTEXT: " &lt;&lt; CTEXT &lt;&lt; endl &lt;&lt; endl;

   while (input.getline(ip, BIGSIZE, '\n'))&#123;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲男人的天堂av| 欧美大片国产精品| 亚洲精品视频自拍| 94色蜜桃网一区二区三区| 中文字幕精品—区二区四季| 国产69精品久久99不卡| 国产欧美一区二区精品秋霞影院| 国产一区二区伦理| 国产精品理论在线观看| 99久久精品免费| 亚洲国产精品久久一线不卡| 91精品国产综合久久小美女 | 国产日本欧美一区二区| 国产99精品视频| 亚洲欧美成人一区二区三区| 欧美亚洲一区二区在线观看| 日韩高清国产一区在线| 久久一日本道色综合| aaa国产一区| 午夜一区二区三区视频| 26uuu色噜噜精品一区二区| 成人黄色大片在线观看| 亚洲午夜影视影院在线观看| 欧美一区二区三区四区视频| 丁香另类激情小说| 亚洲成人久久影院| 精品国产一区二区三区久久久蜜月 | 日韩电影免费一区| 国产视频亚洲色图| 91丨国产丨九色丨pron| 首页亚洲欧美制服丝腿| 中文字幕乱码久久午夜不卡 | 亚洲亚洲人成综合网络| 日韩一区二区在线看片| 91在线一区二区三区| 免费成人av资源网| 亚洲视频在线一区观看| 日韩精品一区二区三区在线| 97精品久久久午夜一区二区三区| 日韩经典一区二区| 亚洲人亚洲人成电影网站色| 日韩一区二区中文字幕| 91久久精品一区二区二区| 国产一区视频网站| 天天av天天翘天天综合网| 久久久久国产精品麻豆ai换脸| 欧美在线一二三四区| 国产高清久久久久| 国产一区二区免费视频| 亚洲sss视频在线视频| 国产精品电影一区二区| 欧美电影免费观看完整版| 欧美亚洲国产怡红院影院| 国产99一区视频免费| 九九精品视频在线看| 五月天视频一区| 亚洲图片激情小说| 日本一区免费视频| 337p粉嫩大胆色噜噜噜噜亚洲 | 欧美日韩国产综合一区二区三区| 国产精品88888| 久久99精品久久只有精品| 亚洲一区二区欧美激情| 亚洲欧美日韩国产中文在线| 国产亚洲欧美激情| 久久只精品国产| 欧美videos中文字幕| 91精品国产91久久久久久最新毛片| 在线亚洲人成电影网站色www| 成人精品在线视频观看| 国产成人在线免费观看| 国产一区二区成人久久免费影院| 免费在线观看不卡| 蜜臀久久99精品久久久画质超高清 | 欧美成人一区二区三区片免费 | 久久精品国产77777蜜臀| 婷婷成人激情在线网| 亚洲成在人线在线播放| 亚洲一区二区三区在线| 一区二区在线观看视频| 一区二区三区高清在线| 一区二区三区四区精品在线视频| 亚洲欧美国产毛片在线| 亚洲裸体xxx| 亚洲午夜激情av| 丝袜亚洲精品中文字幕一区| 午夜不卡av免费| 日本色综合中文字幕| 久久精品国产亚洲a| 国内精品国产成人| 成人手机电影网| 一道本成人在线| 欧美日韩国产在线播放网站| 欧美精品xxxxbbbb| 欧美xingq一区二区| 久久综合九色综合欧美98| 国产日韩欧美一区二区三区综合| 国产精品视频一二| 亚洲综合在线电影| 日本伊人午夜精品| 粉嫩久久99精品久久久久久夜| 成人免费看黄yyy456| 色综合久久天天| 91精品国产色综合久久| 久久婷婷成人综合色| 中文字幕一区二区三区不卡在线| 亚洲综合一区在线| 精品中文字幕一区二区| 丰满岳乱妇一区二区三区| 色婷婷综合久久久| 欧美电影免费观看高清完整版在线 | 亚洲二区视频在线| 久久国产精品区| 99久久婷婷国产| 欧美一区二区三区视频在线观看| 国产网站一区二区| 一区二区三区在线高清| 麻豆精品蜜桃视频网站| k8久久久一区二区三区| 欧美精品第1页| 欧美激情一区在线观看| 亚洲高清不卡在线观看| 国产成人精品亚洲777人妖| 日本精品一级二级| 久久蜜桃av一区二区天堂| 一区二区免费看| 福利一区二区在线观看| 欧美老女人第四色| 亚洲欧洲日韩av| 九九精品视频在线看| 欧美伊人久久久久久久久影院| 久久午夜免费电影| 日韩一区精品字幕| 色婷婷av一区二区三区gif| 欧美精品一区二区三区高清aⅴ| 亚洲另类一区二区| 成人午夜免费电影| 日韩午夜在线观看| 亚洲一区二区在线免费观看视频| 国产一区二区在线观看视频| 欧美日韩一区二区三区在线| 欧美激情综合五月色丁香小说| 日韩精品一二三四| 在线观看免费亚洲| 日韩伦理av电影| 国产成人av影院| 精品国产露脸精彩对白| 偷拍自拍另类欧美| 在线观看视频欧美| 成人欧美一区二区三区1314| 国产精品1区2区3区| 日韩视频不卡中文| 日韩电影在线观看一区| 欧日韩精品视频| 亚洲激情一二三区| 91亚洲精品一区二区乱码| 中文字幕精品—区二区四季| 国产一区二区三区观看| 精品久久久久一区| 免费成人在线观看| 欧美电影一区二区三区| 亚洲高清中文字幕| 欧美日韩你懂得| 亚洲国产精品麻豆| 欧美精品色一区二区三区| 亚洲国产一区视频| 欧洲精品一区二区| 亚洲观看高清完整版在线观看 | 中文一区一区三区高中清不卡| 国产在线精品国自产拍免费| 欧美一区二区三区影视| 日韩av不卡在线观看| 3751色影院一区二区三区| 日韩电影在线看| 精品免费日韩av| 国产成人一区在线| 国产精品久久久久毛片软件| 成人av片在线观看| 亚洲少妇中出一区| 欧美亚洲免费在线一区| 午夜成人在线视频| 精品久久人人做人人爰| 国产激情一区二区三区桃花岛亚洲| 久久精品在线免费观看| 成人午夜视频在线| 一区二区三区在线视频免费观看| 欧美三区在线观看| 美日韩黄色大片| 欧美国产精品中文字幕| 色综合久久综合网欧美综合网| 亚洲一卡二卡三卡四卡| 欧美一级欧美三级| 国产精品一级在线| 亚洲男女一区二区三区| 欧美精品三级在线观看| 国产一区二区久久| 亚洲欧美色图小说| 91精品国产综合久久国产大片 | 成人一级片网址| 亚洲与欧洲av电影|