Jan 16, 2011 04:46 AM
(This post was last modified: Jan 16, 2011 12:50 PM by Ethereal.)
This is my own simple Polymorphic encryption class, released to you for free. I am not going to explain how it works, because if you are interested in writing your own class, you should already know enough to be able to understand this.
Anyway, without further ado, here it is.
Example of Polymorphism:
C#
Usage:
VB .NET(no1me translated)
Usage:
I hope that it is useful to you.
Anyway, without further ado, here it is.
Example of Polymorphism:
C#
Code
class PolyEncryption
{
public string EncryptText(string input, string key)
{
///<summary>
///This function Polymorphically encrypts the entered Text, utilising a Key and Salt.
///All credits to Ethereal of HackForums.net
///Please leave the credits.
///</summary>
Random R = new Random();
int kc = 0;
char[] text = input.ToCharArray();
char[] keyarr = key.ToCharArray();
char[] FinVal = new char[input.Length + 1];
int Rnd = R.Next(100, 220);
for (int index = 0; index < input.Length; index++)
{
if (kc >= keyarr.Length)
kc = 0;
int ptVal = (int)text[index];
int kVal = (int)keyarr[kc];
int ciVal = ptVal + kVal + Rnd;
FinVal[index] = Convert.ToChar(ciVal);
kc++;
}
FinVal[input.Length] = (char)Rnd;
string RetStr = new string(FinVal);
return RetStr;
}
public string DecryptText(string input, string key)
{
///<summary>
///This function decrypts text that was encrypted with the Polymorphic encrypter in this class.
///All credits to Ethereal of HackForums.net
///Please leave the credits.
///</summary>
char[] text = input.ToCharArray();
char[] keyarr = key.ToCharArray();
char[] FinVal = new char[input.Length - 1];
int RndKVal = text[input.Length - 1];
text[input.Length - 1] = '\0';
int kc = 0;
for (int index = 0; index < input.Length; index++)
{
if (index >= input.Length - 1)
continue;
if (kc >= keyarr.Length)
kc = 0;
int ciVal = text[index];
int kVal = keyarr[kc];
int ptVal = ciVal - RndKVal - kVal;
FinVal[index] = Convert.ToChar(ptVal);
kc++;
}
string RetStr = new string(FinVal);
return RetStr;
}
}Usage:
Code
txtBox.Text = PolyEncryption.EncryptText("Test text", "TestKeyVal");
txtBox.Text = PolyEncryption.DecryptText("Test text", "TestKeyVal");VB .NET(no1me translated)
Code
Class PolyEncryption
Public Function EncryptText(ByVal input As String, ByVal key As String) As String
'This function Polymorphically encrypts the entered Text, utilising a Key and Salt.
'All credits to Ethereal of HackForums.net
'Please leave the credits.
Dim R As New Random()
Dim kc As Integer = 0
Dim text As Char() = input.ToCharArray()
Dim keyarr As Char() = key.ToCharArray()
Dim FinVal As Char() = New Char(input.Length) {}
Dim Rnd As Integer = R.[Next](100, 220)
For index As Integer = 0 To input.Length - 1
If kc >= keyarr.Length Then
kc = 0
End If
Dim ptVal As Integer = AscW(text(index))
Dim kVal As Integer = AscW(keyarr(kc))
Dim ciVal As Integer = ptVal + kVal + Rnd
FinVal(index) = Convert.ToChar(ciVal)
kc += 1
Next
FinVal(input.Length) = ChrW(Rnd)
Dim RetStr As New String(FinVal)
Return RetStr
End Function
Public Function DecryptText(ByVal input As String, ByVal key As String) As String
'This function decrypts text that was encrypted with the Polymorphic encrypter in this class.
'All credits to Ethereal of HackForums.net
'Please leave the credits.
Dim text As Char() = input.ToCharArray()
Dim keyarr As Char() = key.ToCharArray()
Dim FinVal As Char() = New Char(input.Length - 2) {}
Dim RndKVal As Integer = AscW(text(input.Length - 1))
text(input.Length - 1) = ControlChars.NullChar
Dim kc As Integer = 0
For index As Integer = 0 To input.Length - 1
If index >= input.Length - 1 Then
Continue For
End If
If kc >= keyarr.Length Then
kc = 0
End If
Dim ciVal As Integer = AscW(text(index))
Dim kVal As Integer = AscW(keyarr(kc))
Dim ptVal As Integer = ciVal - RndKVal - kVal
FinVal(index) = Convert.ToChar(ptVal)
kc += 1
Next
Dim RetStr As New String(FinVal)
Return RetStr
End Function
End ClassUsage:
Code
TextBox1.Text = PolyEncryption.EncryptText(TextBox1.Text, TextBox3.Text)
TextBox1.Text = PolyEncryption.DecryptText(TextBox1.Text, TextBox3.Text)μεγαλομανία



![[Image: rudeboy_1.png]](https://image.ibb.co/deZDd5/rudeboy_1.png)
![[Image: zK5GzfG.gif]](https://i.imgur.com/zK5GzfG.gif)
