Cryptograph Implementation Part 3 (Symmetric Key Cryptograph)

Advertisement
symmetric key cryptograph implementation | internet blog, computer how to, SEO blog | Kartolo Cyber Center
This Symmetric Key Cryptograph was the continuation of One-way cryptograph implementation and Two-way cryptograph implementation. What is meant by symmetric key is a key parameters used in the encrypt and decrypt, the same. The length of this key parameter varies depending on the method used. In the implementation of which will be given, the method used is RC4 and Blowfish, with a key length of 128 bits or 16 bytes.

For some reason, the implementation will be given and discussed starting from the first decrypt. Decrypt Implementation can be downloaded at this linkAgain, this implementation emulate a serial verification software, but of course, is made as simple as possible, so that the more prominent kriptografinya. Thus, this implementation is a "recipient" message, then tried to decrypt the message and posted verikasikan whether the message originated from the "sending" a message is legitimate or not.

The files contained in this implementation, it is not much different from what is on the implementation of cryptographic one-way, only the library has changed the method in question. Main code, again located in the "Unit1.pas". Let us open the code to start dissecting this implementation.

Lines 33 through to 87, shows two function to download decrypt with each method. The process decrypt the two methods is made uniform in order to avoid confusion, and certainly not a standard form. What is different of course, the core algorithm of each method are contained in the *. Fitting respectively. Because of this uniformity, the discussion of the method can represent only one method.

On line 35 we can see, the initialization of key constants are prepared to decrypt process. Key was made with the format of the byte array with width 16. Or, in other words, has a key length of 16 bytes, or 128 (16 * 8) bits. It should be noted is that in Delphi, the notation "$" indicates that the number is written in hexadecimal form. Thus, the declaration of the array could be written like this:

key: array [0 .. 15] of byte = (71,114,105,110,100,83,116,111,110,101,73,115,71,111,111,100); Above the array declaration using decimal notation, with the same value. Then, why the implementation is written with hexadecimal notation? I just love hex, nothing more.

Okay, let's look at lines 39 and 40. There are two variables declared array to hold the input and output of the process decrypt it. Because what is done today is the decrypt, then the input is accommodated in the Cipher Text arrCipher variable, while the output is accommodated in Plain Text arrPlain variable. Both variables are created equal length is 8 bytes. It is worth noting, because it will affect the use of this function, we will get to it later.

Decrypt function accepts a String as a parameter in the form of input, as shown in line 33, while variables that are inputs to the core decrypt shaped array of bytes, as shown in line 51. Thus, lines 44 to 48, the duty to convert the String variable into an array of bytes. There are many methods that can be used for this task, such as taking the ASCII value of each character in the string, and then store them into an array of bytes. However, in this implementation, the method to be used is, take every 2 (two) characters from the string, and then added the notation "$" in front of it to then change into the form of a byte (integer) and stored in the array. And this is done with the loop as much as 8 (0-7) rounds, because the length of an existing variable placeholders (arrCipher) is 8. Therefore, the length of a valid string to be input into this function is 16 (8 * 2) character, and the character that is to be character hexadecimal number, ie 1-9 and AF. Let us take an example to clarify:

For example, strings that are input are: "1234567890ABCDEF" Then the array of bytes that is formed is: ($ 12, $ 34, $ 56, $ 78, $ 90, $ AB, $ CD, $ EF) or in decimal form is: (18, 52, 86, 120, 144, 171, 205, 239) Hopefully the above is clear enough to describe the "flow" of such conversion algo. Lines 49 through 52 is the code to decrypt the core process required by this DCPCrypt library. And the results of the core is stored in decrypt variable arrPlain shaped array of bytes. Line 53 to prepare (empty) strResult variable that will hold the result of the function decrpyt this. If the input we had to convert from String variable to an array of bytes, now we are doing the opposite for output, change the variable array of bytes into a String. And that is done on lines 54 to 57. The method used now is take each byte of the array, and then download the subtitusikannya with the character that has the ASCII value is concerned, to be added in the strResult variable. This method is much simpler than previous methods, but let's take an example to better clarify:

For example, the variable arrPlain are: (71, 119, 84, 97, 109, 112, 97, 110) then in the strResult variable is created: "GwTampan"

Hopefully, the above example could clarify what exactly is self-explanatory. : D Thus the explanation of the functions that used to decrypt. These functions need to be fully understood if we are to make the process necessary to make encrypted keygen of "software" verification. We will discuss it in the next implementation. For now, let's go to the core functions of the program, which is executed when the user presses the button "Check".

This function is, of course, lies in the lines 89 to 144. Seen a lot of ramifications "if" in there, which may confuse some people. If that's the case, with all humility, I apologize for my poor pemogramman way. But I think, these subdivisions do not need to discuss all, because just to check basic errors from user input. Its worth mentioning is branching on line 113. You can see that if the "Name" the user inputted more than 8 characters, it is taken only the first 8 characters only. And if the "name" that is inputted is less than 8 characters, then the variables are duplicated continuously for more than 8, to then take the first 8 characters.

Again, an example to clarify: For example, the name of the input is: "CryptographyIsSuperFun" then, taken only: "Cryptogr" And, if the name of the input is: "FUN" hence, the result will be: "FUNFUNFU"

With this, we are "forced" strName variable to fixed length of 8 characters, no matter how many characters are inputted by the user. Why? Before you answer, I hope you still remember the characteristics of the above function decrypt earlier, valid input must be a string with 16 characters (this explains the ramifications on line 107), and the resulting output is a string with 8 characters. And on line 133, there is a "final check" that compares the variable strName strPlain which is the result of the series that Decrypt inputted. Auto, strPlain will always have a length of 8 characters, that's why we need to "force" strName to still have a length of 8 characters.

Actually there is a little "bug" that is quite disturbing in this implementation. That is, when we enter the serial with length of 16 characters, but the character of the input is not a hexadecimal character, it will display an error message that is less good. But of course, it can be overcome by adding branching to check whether the serial input is hexadecimal character or not. You can add it if you want!
Advertisement
Cryptograph Implementation Part 3 (Symmetric Key Cryptograph) | KartoloCyber | 5

0 comments:

Post a Comment