Saturday, March 24, 2012

[PHP] Factorial

          Hello, Reader ^^! Back again with source code. This time is a simple Factorial which is written in PHPprogramming language. This one will calculate factorial calculation. The GUI is still viewed with HTML but when the button is pressed, the PHP will work calculating the input you put. Okay, that's all I can say. Thank you for reading ^^!


Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





[PHP] Hello World

          Hello, Reader ^^! Back again with source code. This time is a simple Hello World. Yeah, it is Hello World again but this time with PHP programming language. Well, I have assignments which need PHP to do it so I decided to learn this too and post some example of it here. Okay, that's all I can say. Thank you for reading ^^!

Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Friday, March 23, 2012

[Ruby] [Shoes] Hello World

          Hello, Reader ^^! Back again with source code. This time is a simple Hello World. Yeah, it is a Hello World again with Ruby, but this time, the GUI "Shoes" is implemented. With this, I can put graphical elements to the program. In this example. a popup will appear if you click the button. Okay, that's all I can say. Thank you for reading ^^!


Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Thursday, March 22, 2012

[C#] OFB (Output Feedback)

          Hello, Reader ^^! Back again with source code. This time is is OFB (Output Feedback) which is made using C# programming language. This one, like CFB, also encrypts block per block from previous blocks. The first block came from Initialization Vector. The difference is the OFB uses Encryption Block from previous Encryption Block. The Encryption Block used in this example is the simple XOR. You can define your own Encryption Block like doing shift left, shift right, etc. Now, let me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 10101
IV generated : 10001
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000






IV(only 1st block), then from the Third row 10001 001001000100100 
Key10101 10101 10101 10101 
Encryption Block (a xor b; a is IV, b is key) 00100100010010010001
Plaintext (in bits)
01011 11111 01010 10000
Xor-ed (Plaintext with third row)  
01111011100111000001


The result of encryption is 01111011100111000001.

Okay, that's all I can say. Thank you for reading ^^!



Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





[C#] CFB (Cipher Feedback)

          Hello, Reader ^^! Back again with source code. This time is is CFB (Cipher Feedback) which is made using C# programming language. This one, like CBC, also encrypts block per block from previous blocks. The first block uses Initialization Vector. The IV (and the next xor-ed plaintext and Encryption Block), will be encrypted into Encryption Block. After that, it will xor-ed with plaintext which will be the ciphertext. A mistake just a bit can lead mistake also in the encryption and decryption. The Encryption Block used in this example is the simple XOR. You can define your own Encryption Block like doing shift left, shift right, etc. Now, let me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 10101
IV generated 10001
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000




IV(only 1st block), then from the Fifth row 10001 10001 11011 01110 
Key01011 10101 11111 00000 
Encryption Block (a xor b; a is first row, b is key) 11010001000010001110
Plaintext (in bits)
01011 11111 01010 10000
Xor-ed (Plaintext with third row)  
10001110110111011111


The result of encryption is 10001110110111011111. If you see at the 3rd column, at the 2nd row, you will see the value is taken from 2nd column, 5th row. Yup, that's why it is chaining.

Okay, that's all I can say. Thank you for reading ^^!


Download Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





[C#] CBC (Cipher-Block Chaining)

          Hello, Reader ^^! Back again with source code. This time is is CBC (Cipher-Block Chaining) which is made using C# programming language. This one, uses encryption per block which came from the previous block. This way, the encryption becomes stronger, not only that, with Initialization Vector which is generated random, it made encryption more unique even with the same key. The IV can be kept or not, because when decryption, it won't effect the other block not like when enciphering. The Encryption Block used in this example is the simple XOR. You can define your own Encryption Block like doing shift left, shift right, etc. Now, let me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 10101
IV generated 10001
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000





Plaintext(in bits)01011111110101010000
IV(only 1st block), then from the Encryption Block 01011 10101 11111 00000 
Xor-ed (Plaintext with second row)00000010101010110000 
Key1010110101 10101 10101 
Encryption Block (a xor b; a is xor-ed bits, b is key)10101111110000000101


The result of encryption is 10101111110000000101. If you see at the 3rd column, at the 2nd row, you will see the value is taken from 2nd column, 5th row. Yup, that's why it is chaining.

One more thing, it also can encrypt and decrypt file like the other block cipher mode :D (I forgot to mention it with toher block cipher mode). Okay, that's all I can say. Thank you for reading ^^!



Download Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Wednesday, March 21, 2012

[C#] ECB (Electronic Code Book)

          Hello, Reader ^^! Back again with source code. This time is is ECB (Electronic Code Book) which is made using C# programming language. There was a problem making it when facing the Unicode conversion to Binary and vice versa, but finally, it is solved :3. Now, Let me explain it again like the C++ before. Encryption using ECB is separating plaintext bit into blocks (key). After that, each block each encrypted with the block key. When the plaintext's length is not divideable by the key's length, pad it with all 0s or all 1s or 101010... In this example, the Encryption Block used is a simple xor. You can define your own Encryption Block. Now, let's me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 01101
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000






Plaintext(in bits)01011111110101010000
Key per block01011010110101101011
Encryption Block  (a xor b; a is Plaintext, b is key)00000101000000111011


The result of encryption is 00000101000000111011

Okay, that's all I can say. Thank you for reading ^^!


Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Monday, March 19, 2012

[Ruby] Rail Fence Cipher Extended

          Hello, Reader ^^! Back again with source code. This time is a  Rail Fence Cipher Extended which is made from Ruby programming language. This one is a bit difficult and tricky. The formula needed is also tricky. The coding of encryption is easier than the decryption. The difference with the normal version is that the Extended version also accept non-number and non-alphabet character. The alphaber is case-sensitive in this version. Now for a bit of demonstration:


Take a string "Hello World!" 
Don't remove any character unlike the non-extended version.


Now, let's arrange them like this:


H   o   r
 e l   o l !
  l   w   d


Now, based on its arranged form, from left to right and below, it is turned into HOLELWRDLO as the encryption result. That's how the Rail Fence Cipher do.


Okay, that's all I can say. Thank you for reading ^^!


Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





[Ruby] OFB (Output Feedback)

          Hello, Reader ^^! Back again with source code. This time is is OFB (Output Feedback) which is made using Ruby programming language. This one, like CFB, also encrypts block per block from previous blocks. The first block came from Initialization Vector. The difference is the OFB uses Encryption Block from previous Encryption Block. The Encryption Block used in this example is the simple XOR. You can define your own Encryption Block like doing shift left, shift right, etc. Now, let me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 10101
IV generated : 10001
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000





IV(only 1st block), then from the Third row 10001 001001000100100 
Key10101 10101 10101 10101 
Encryption Block (a xor b; a is IV, b is key) 00100100010010010001
Plaintext (in bits)
01011 11111 01010 10000
Xor-ed (Plaintext with third row)  
01111011100111000001


The result of encryption is 01111011100111000001.

Okay, that's all I can say. Thank you for reading ^^!



Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Saturday, March 17, 2012

[Ruby] CFB (Cipher Feedback)

          Hello, Reader ^^! Back again with source code. This time is is CFB (Cipher Feedback) which is made using Ruby programming language. This one, like CBC, also encrypts block per block from previous blocks. The first block uses Initialization Vector. The IV (and the next xor-ed plaintext and Encryption Block), will be encrypted into Encryption Block. After that, it will xor-ed with plaintext which will be the ciphertext. A mistake just a bit can lead mistake also in the encryption and decryption. The Encryption Block used in this example is the simple XOR. You can define your own Encryption Block like doing shift left, shift right, etc. Now, let me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 10101
IV generated 10001
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000







IV(only 1st block), then from the Fifth row 10001 10001 11011 01110 
Key01011 10101 11111 00000 
Encryption Block (a xor b; a is first row, b is key) 11010001000010001110
Plaintext (in bits)
01011 11111 01010 10000
Xor-ed (Plaintext with third row)  
10001110110111011111


The result of encryption is 10001110110111011111. If you see at the 3rd column, at the 2nd row, you will see the value is taken from 2nd column, 5th row. Yup, that's why it is chaining.

Okay, that's all I can say. Thank you for reading ^^!


Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





[Ruby] CBC (Cipher-Block Chaining)

          Hello, Reader ^^! Back again with source code. This time is is CBC (Cipher-Block Chaining) which is made using Ruby programming language. This one, uses encryption per block which came from the previous block. This way, the encryption becomes stronger, not only that, with Initialization Vector which is generated random, it made encryption more unique even with the same key. The IV can be kept or not, because when decryption, it won't effect the other block not like when enciphering. The Encryption Block used in this example is the simple XOR. You can define your own Encryption Block like doing shift left, shift right, etc. Now, let me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 10101
IV generated 10001
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000





Plaintext(in bits)01011111110101010000
IV(only 1st block), then from the Encryption Block 01011 10101 11111 00000 
Xor-ed (Plaintext with second row)00000010101010110000 
Key1010110101 10101 10101 
Encryption Block (a xor b; a is xor-ed bits, b is key)10101111110000000101


The result of encryption is 10101111110000000101. If you see at the 3rd column, at the 2nd row, you will see the value is taken from 2nd column, 5th row. Yup, that's why it is chaining.

Okay, that's all I can say. Thank you for reading ^^!


Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





[Ruby] ECB (Electronic Code Book)

          Hello, Reader ^^! Back again with source code. This time is is ECB (Electronic Code Book) which is made using Ruby programming language. Let me explain it again like the C++ before. Encryption using ECB is separating plaintext bit into blocks (key). After that, each block each encrypted with the block key. When the plaintext's length is not divideable by the key's length, pad it with all 0s or all 1s or 101010... In this example, the Encryption Block used is a simple xor. You can define your own Encryption Block. Now, let's me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 01101
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000





Plaintext(in bits)01011111110101010000
Key per block01011010110101101011
Encryption Block  (a xor b; a is Plaintext, b is key)00000101000000111011


The result of encryption is 00000101000000111011

Okay, that's all I can say. Thank you for reading ^^!


Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Thursday, March 15, 2012

[Ruby] Rail Fence Cipher

          Hello, Reader ^^! Back again with source code. This time is a  Rail Fence Cipher which is made from Ruby programming language. This one is a bit difficult and tricky. The formula needed is also tricky. The coding of encryption is easier than the decryption. Now for a bit of demonstration:


Take a string "Hello World!"
Remove all non-number and non-alphabet. Uppercase all of the string. Remove all the space. The result:
"HELLOWORLD"


Now, let's arrange them like this:


H   O   L
 E L W R D
  L   O


Now, based on its arranged form, from left to right and below, it is turned into HOLELWRDLO as the encryption result. That's how the Rail Fence Cipher do.


Okay, that's all I can say. Thank you for reading ^^!


Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Wednesday, March 14, 2012

[Python] Factorial

          Hello, Reader ^^! Back again with source code. This time is a simple Factorial. This time is with Python. Well, this one just doing a factorial calculation. It also checks whether the input is string or below 0. If that happens, error will occur. Plus, no result will be returned into the prompt. Okay, that's all I can say. Thank you for reading ^^!


Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Monday, March 12, 2012

[Ruby] ROT13

          Hello, Reader ^^! Back again with source code. This time is a simple ROT13. This one is a bit tricky but still easy. Playing with ASCII index is needed. To check whether a character is an alphabet, simple use the regular expression /[A-Z]/ for uppercase and /[a-z]/ for regular case. After that, switch the index by 13, then you will get the ROT13 result. Okay, that's all I can say. Thank you for reading ^^!



Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





[Ruby] Palindrome Check

          Hello, Reader ^^! Back again with source code. This time is a simple Palindrome Check. The only needed is using the built-in reverse function. Then compare it with the original string. If equal, then it is palindrome. Example, a string "pizza azzip" is a palindrome. One more thing, in this example, it is case-sensitive. Okay, that's all I can say. Thank you for reading ^^!



Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Sunday, March 11, 2012

[Ruby] Factorial

          Hello, Reader ^^! Back again with source code. This time is a simple Factorial. Yup, it is just doing a factorial operation :p. This one shows how to create a function and raise (Ruby exception version). It handles whether the input is lower than 0. The operation is also using recursive method. Okay, that's all I can say. Thank you for reading ^^!


Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Saturday, March 10, 2012

[Python] Hello World

          Hello, Reader ^^! Back again with source code. This time is a simple Hello World. This time is with Python. It's been a while too since I used Python to try a game engine using this xD. Well, it is time to warm up too with this programming language before starting with the main problem with this xD. Okay, that's all I can say. Thank you for reading ^^!



Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





[C++] String To Binary String

          Hello, Reader ^^! Back again with source code. This time is a simple String To Binary String. This function can convert string into binary string. I only need to use itoa and some 0 padding to do it. Now, let's me give a demonstration. If you put "I want a pizza!" string, it will be converted into "010010010010000001110111011000010110111001110100001000000110000100100000011100000110100101111010011110100110000100100001". Oh, I made this one since it is hard to find any example to convert a string into binary string >.< which pushed me into making this example :3. Okay, that's all I can say. Thank you for reading ^^!



Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Friday, March 9, 2012

[Ruby] Hello World

          Hello, Reader ^^! Back again with source code. This time is a simple Hello World. Yup, it's been a while since I have been using Ruby and haven't posted any source code with Ruby so I decided to warm up myself first before I posted source code which is made from Ruby. Okay, that's all I can say. Thank you for reading ^^!



Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





[C++] ECB (Electronic Code Book)

          Hello, Reader ^^! Back again with source code. This time is is ECB (Electronic Code Book) which is made using C++. Encryption using ECB is separating plaintext bit into blocks (key). After that, each block each encrypted with the block key. When the plaintext's length is not divideable by the key's length, pad it with all 0s or all 1s or 101010... In this example, the Encryption Block used is a simple xor. You can define your own Encryption Block. Now, let's me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 01101
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000






Plaintext(in bits)01011111110101010000
Key per block01011010110101101011
Encryption Block = a xor b 00000101000000111011


The result of encryption is 00000101000000111011
Now, in this one I made, to be able both the key and the plaintext readable, I also pad the key until it is dividable by 8.

Okay, that's all I can say. Thank you for reading ^^!



Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





Wednesday, March 7, 2012

[Javascript] Ranged Random Numbers Generator

          Hello, Reader ^^! Back again with source code. This time is Ranged Random Numbers Generator which is coded using Javascript. This one is easy too. This one will generate random numbers in range. Plus, it also checks whether the input is number or not and checks whether the maximum is higher than minimum. Okay, that's all I can say. Thank you for reading ^^!



Try it here





Download/View Source Code
- Dropbox
- Dropbox (Repository)
- GitHub
GitHub (Repository)





[Javascript] Content Based Radio Choice

          Hello, Reader ^^! Back again with source code. This time is Content Based Radio Choice which is coded using Javascript. This one is easy. This one will generate content based on the choice which radio button is activated. It also changes when the radio button's which is clicked changed too. Okay, that's all I can say. Thank you for reading ^^!


Radio buttons, not selected

Radio buttons, selected which generates content based on choice


Try it here





Download/View Source Code
Dropbox
Dropbox (Repository)
GitHub
GitHub (Repository)





Tuesday, March 6, 2012

[Javascript] Comment Simulation

          Hello, Reader ^^! Back again with source code. This time is Comment Simulation which is coded using Javascript. This one is more tricky. I use InnerHTML approach to add new comment. The one will simulate comments which the comment comes from the comment form. Btw, I deactivated the HTML tag effect for security reason. Okay, that's all I can say. Thank you for reading ^^!

Comment form, with no comment yet

Comments and the Comment Form


Try it here






Download/View Source Code
Dropbox
Dropbox (Repository)
GitHub
GitHub (Repository)





Monday, March 5, 2012

[Javascript] Spoiler

          Hello, Reader ^^! Back again with source code. This time is Spoiler which is coded using Javascript. This one is a bit tricky, but still easy to do if you get better with the javascript, css, and html. This one will  show or hide content when the button is pressed. Also, the spoiler box gets bigger each time the input from the text area gets bigger too. One more thing, you can also use html tag for more effect .Okay, that's all I can say. Thank you for reading ^^!


Content is Visible


Content is Hidden


Try it here





Download/View Source Code
Dropbox
Dropbox (Repository)
GitHub
GitHub (Repository)





Saturday, March 3, 2012

[Javascript] Factorial

          Hello, Reader ^^! Back again with source code. This time is Factorial which is coded using Javascript. This one is using recursion to get the result. It also checks whether the input is full number or not. The checking is using regexp so it would be easier to test whether it is full number or not. Okay, that's all I can say. Thank you for reading ^^!




Try it here





Download/View Source Code
Dropbox
Dropbox (Repository)
GitHub
GitHub (Repository)