|
Transposition Encryption or
Geometrical Pattern Encoding Encryption Decryption technique
written in Visual Basic .NET.
Click here to
Download the source code.
Introduction
In transposition and geometrical pattern encoding the text
is rearranged with the aid of some type of geometric figure,
a typical example being a two - dimensional array or a
matrix, First plain text message is written into the figure
according to a particular matrix, the cipher text then
created by taking the letters off the matrix according to a
different path. |
1.
Encryption / Decryption
|
|
|
Screen shot

Logics
First we set our matrix, it is a multidirectional array,
user can set the array dimension, the pattern of cipher text
depends on matrix dimension. After creating the array we put
plain text character by character into the array pocket,
when the array is filled we moved the text from the array to
the temporary string variable, then reset the array and
continue until the plain text is completely covered.
For j = i
To LastPos
'>>> check if need
to XOR the character
If
ChkXOR.Checked = True
Then
Dim
TempChar As
String
TempChar = Mid(StrDataIn, j, 1)
DataArray(r, c) = Chr(Asc(TempChar)
Xor XORCode)
Else
DataArray(r, c) = Mid(StrDataIn,
j, 1)
End
If
c = c + 1
'>>> reset the
array indexer
If r
> IndR - 1 Then
r = 0
c = 0
End
If
If c
> IndC - 1 Then
c = 0
r = r + 1
End
If
Next
After that we transpose the
array by row and column, here you can improve if you want,
you can create another array to order the transposition.
After transposition loop the array and concatenate all the
array element into and string variable and return it as a
cipher text. If you check the XOR option it will XOR the
output cipher text. In case of decryption you need to
transpose the array in reverse order to get the plain text.
Lastly remove the filler character from the final output, we
use chr(1).
Dim StrTemp
As
String
StrTemp = ""
Dim p, p1
As
Integer
p = 1
p1 = 1
For r = 0
To IndR - 1
For c = 0
To IndC - 1
StrTemp = StrTemp & DataArray(r, c)
Next
Next
While p <=
StrTemp.Length
'>>> replace array
filling character
'>>> check if
it is xor
If
ChkXOR.Checked = True
Then
StrOut = StrOut & Replace(Mid(StrTemp,
p1, 1), _
Chr(Asc(Chr(1)) Xor XORCode),
"")
Else
StrOut = StrOut & Replace(Mid(StrTemp,
p1, 1), Chr(1), "")
End If
p = p + 1
'>>> increment
position by row
p1 = p1 + IndR
If p1 >
StrTemp.Length Then
p1 = p1 - StrTemp.Length + 1
End
If
End
While
If you combine Transposition
Encryption with XOR Encryption it will produce near to
impossible cipher text. May be for professional hacker,
cracker it is not very hard to break, however for normal
security need and easy to implement it is quite used today.
Download the source code and project files |