Login Register




The stories and information posted here are artistic works of fiction and falsehood. Only a fool would take anything posted here as fact.


[TUT]What is Encryption? filter_list
Author
Message
[TUT]What is Encryption? #1
Its a method to convert text into a text which is not the original to protect information and data.

Encryption was first used in the world war 2. If spies would carry letters with regular text and were caught they will all be in danger so the Germans invented a machine with the Enigma Cipher which was a strong encryption cipher to encrypt messages. Of course later a Polish Engineer was able to find a Decryption Cipher to see the regular text of that message. After that there was many secrets found in the letters and many counter attacks leaded to Germany's weakness.

After the war was ended even now there are thousands of Encryption ciphers which we use daily. There are famous Encryptions such as MD5, RC4 and Triple-DES.

What is a cipher?
Its a method of protecting text. The MD5 is a cipher. RC4 is a cipher. Enigma is a Cipher.

Ok to make you understand more clearly lets do a demonstration.

Text: hackcommunity
Cipher: Replace a with 5, replace m with 2, replace i with 1
Output: h5ckco22un1ty

Now you understand what i mean? Smile

Some Text need a key to be Encrypted for even more protection. RC4 requires a key which can even be a blank space. You can later decrypt the Encrypted text with the key or you can brute force the key with special programs of course that will take time.

Encryption is mostly used these days in Mails. Why?
No one is safe. You might be hacked someday and have really important messages including credit card passwords, phone numbers, addresses, names, political issues, secret matters, ... in the hands of the hacker.

To prevent something like that you can make a deal with the person your mailing. Like for example that person knows your name in English, You can send him a RC4 encrypted text telling him the key is my real name only then the receiver ONLY can read the protected text.

There are sites which offer online Encryption such as www.crypo.com which i recommend highly due to many ciphers available.

Encryptions are also used in hack tools to prevent detection and increase UD ( Undetectability ). For example, a string stored in the program can be: "KillAntiVirus" which can be a detection, we can use functions to decrypt a protected text. For example we used hex cipher to encrypt that text. it will now be:
Code:
4b 69 6c 6c 41 6e 74 69 56 69 72 75 73

And using it with a function will be:
Code:
DecryptHex("4b 69 6c 6c 41 6e 74 69 56 69 72 75 73")
Which will result in returning our original text

Here is a few functions in VB.NET and C# which you can use to encrypt and decrypt your programs with (credits to hackyer):


[VB.NET]
Spoiler: MD5
Code:
Public Function MD5Hash(ByVal input As String) As String Dim MD5 As New System.Security.Cryptography.MD5CryptoServiceProvider Dim Data As Byte() Dim Result As Byte() Dim Res As String = "" Dim Tmp As String = "" Data = System.Text.Encoding.ASCII.GetBytes(input) Result = MD5.ComputeHash(Data) For i As Integer = 0 To Result.Length - 1 Tmp = Hex(Result(i)) If Len(Tmp) = 1 Then Tmp = "0" & Tmp Res += Tmp Next Return Res End Function



[VB.NET]
Spoiler: Hex Encode
Code:
Public Function Hex_Encrypt(ByVal input As String) As String Dim out As New System.Text.StringBuilder For Each c As String In input Dim temp As String = Hex(Asc(c)) out.Append(temp & " ") Next Return out.ToString.Substring(0, out.Length - 1) End Function



[VB.NET]
Spoiler: Hex Decode
Code:
Public Function Hex_Decrypt(ByVal input As String) As String Dim out As New System.Text.StringBuilder Dim data As String() = Split(input, " ") For Each s As String In data out.Append(Chr("&H" & s)) Next Return out.ToString End Function



[VB.NET]
Spoiler: Triple-DES Encode
Code:
Public Function TripleDES_Encrypt(ByVal input As String, ByVal pass As String) As String Dim TripleDES As New System.Security.Cryptography.TripleDESCryptoServiceProvider Dim Hash_TripleDES As New System.Security.Cryptography.MD5CryptoServiceProvider Dim encrypted As String = "" Try Dim hash(23) As Byte Dim temp As Byte() = Hash_TripleDES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass)) Array.Copy(temp, 0, hash, 0, 16) Array.Copy(temp, 0, hash, 15, 8) TripleDES.Key = hash TripleDES.Mode = Security.Cryptography.CipherMode.ECB Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = TripleDES.CreateEncryptor Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input) encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length)) Return encrypted Catch ex As Exception End Try End Function



[VB.NET]
Spoiler: Triple-DES Decode
Code:
Public Function TripleDES_Decrypt(ByVal input As String, ByVal pass As String) As String Dim TripleDES As New System.Security.Cryptography.TripleDESCryptoServiceProvider Dim Hash_TripleDES As New System.Security.Cryptography.MD5CryptoServiceProvider Dim decrypted As String = "" Try Dim hash(23) As Byte Dim temp As Byte() = Hash_TripleDES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass)) Array.Copy(temp, 0, hash, 0, 16) Array.Copy(temp, 0, hash, 15, 8) TripleDES.Key = hash TripleDES.Mode = Security.Cryptography.CipherMode.ECB Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = TripleDES.CreateDecryptor Dim Buffer As Byte() = Convert.FromBase64String(input) decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length)) Return decrypted Catch ex As Exception End Try End Function



[VB.NET]
Spoiler: RC4 Encode
Code:
Public Function RC4_Encrypt(ByVal message As String, ByVal password As String) As String Dim i As Integer = 0 Dim j As Integer = 0 Dim cipher As New StringBuilder Dim returnCipher As String = String.Empty Dim sbox As Integer() = New Integer(256) {} Dim key As Integer() = New Integer(256) {} Dim intLength As Integer = password.Length Dim a As Integer = 0 While a <= 255 Dim ctmp As Char = (password.Substring((a Mod intLength), 1).ToCharArray()(0)) key(a) = Microsoft.VisualBasic.Strings.Asc(ctmp) sbox(a) = a System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1) End While Dim x As Integer = 0 Dim b As Integer = 0 While b <= 255 x = (x + sbox(b) + key(b)) Mod 256 Dim tempSwap As Integer = sbox(b) sbox(b) = sbox(x) sbox(x) = tempSwap System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1) End While a = 1 While a <= message.Length Dim itmp As Integer = 0 i = (i + 1) Mod 256 j = (j + sbox(i)) Mod 256 itmp = sbox(i) sbox(i) = sbox(j) sbox(j) = itmp Dim k As Integer = sbox((sbox(i) + sbox(j)) Mod 256) Dim ctmp As Char = message.Substring(a - 1, 1).ToCharArray()(0) itmp = Asc(ctmp) Dim cipherby As Integer = itmp Xor k cipher.Append(Chr(cipherby)) System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1) End While returnCipher = cipher.ToString cipher.Length = 0 Return returnCipher End Function



[VB.NET]
Spoiler: Base64 Encode/Decode
http://www.hackcommunity.com/Thread-VB-Net-Base64-Encode-Decode



[VB.NET]
Spoiler: Binary Encode
Code:
Public Function Binary_Encrypt(Byval input As string) As string Dim Val As String = Nothing Dim Characters As String = System.Text.RegularExpressions.Regex.Replace(input, "[^01]", "") Dim ByteArray((Characters.Length / 8) - 1) As Byte For Index As Integer = 0 To ByteArray.Length - 1 ByteArray(Index) = Convert.ToByte(Characters.Substring(Index * 8, 8), 2) Next Val = System.Text.ASCIIEncoding.ASCII.GetString(ByteArray) Return Val End Function



[VB.NET]
Spoiler: Binary Decode
Code:
Public Function Binary_Decrypt(Byval input As String) As String Dim Val As String = Nothing Dim Result As New System.Text.StringBuilder For Each Character As Byte In System.Text.ASCIIEncoding.ASCII.GetBytes(input) Result.Append(Convert.ToString(Character, 2).PadLeft(8, "0")) Result.Append(" ") Next Val = Result.ToString.Substring(0, Result.ToString.Length - 1) Return Val End Function






[C#]
Spoiler: MD5
Code:
public string MD5Hash(string input) { System.Security.Cryptography.MD5CryptoServiceProvider MD5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] Data = null; byte[] Result = null; string Res = ""; string Tmp = ""; Data = System.Text.Encoding.ASCII.GetBytes(input); Result = MD5.ComputeHash(Data); for (int i = 0; i <= Result.Length - 1; i++) { Tmp = Conversion.Hex(Result[i]); if (Strings.Len(Tmp) == 1) Tmp = "0" + Tmp; Res += Tmp; } return Res; }



[C#]
Spoiler: Hex Encode
Code:
public string Hex_Encrypt(string input) { System.Text.StringBuilder @out = new System.Text.StringBuilder(); foreach (string c in input) { string temp = Conversion.Hex(Strings.Asc(c)); @out.Append(temp + " "); } return @out.ToString().Substring(0, @out.Length - 1); }



[C#]
Spoiler: Hex Decode
Code:
public string Hex_Decrypt(string input) { System.Text.StringBuilder @out = new System.Text.StringBuilder(); string[] data = Strings.Split(input, " "); foreach (string s in data) { @out.Append(Strings.Chr("&H" + s)); } return @out.ToString(); }



[C#]
Spoiler: Triple-DES Encode
Code:
public string TripleDES_Encrypt(string input, string pass) { System.Security.Cryptography.TripleDESCryptoServiceProvider TripleDES = new System.Security.Cryptography.TripleDESCryptoServiceProvider(); System.Security.Cryptography.MD5CryptoServiceProvider Hash_TripleDES = new System.Security.Cryptography.MD5CryptoServiceProvider(); string encrypted = ""; try { byte[] hash = new byte[24]; byte[] temp = Hash_TripleDES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass)); Array.Copy(temp, 0, hash, 0, 16); Array.Copy(temp, 0, hash, 15, 8); TripleDES.Key = hash; TripleDES.Mode = System.Security.Cryptography.CipherMode.ECB; System.Security.Cryptography.ICryptoTransform DESEncrypter = TripleDES.CreateEncryptor(); byte[] Buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(input); encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length)); return encrypted; } catch (Exception ex) { } }



[C#]
Spoiler: Triple-DES Decode
Code:
public string TripleDES_Decrypt(string input, string pass) { System.Security.Cryptography.TripleDESCryptoServiceProvider TripleDES = new System.Security.Cryptography.TripleDESCryptoServiceProvider(); System.Security.Cryptography.MD5CryptoServiceProvider Hash_TripleDES = new System.Security.Cryptography.MD5CryptoServiceProvider(); string decrypted = ""; try { byte[] hash = new byte[24]; byte[] temp = Hash_TripleDES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass)); Array.Copy(temp, 0, hash, 0, 16); Array.Copy(temp, 0, hash, 15, 8); TripleDES.Key = hash; TripleDES.Mode = System.Security.Cryptography.CipherMode.ECB; System.Security.Cryptography.ICryptoTransform DESDecrypter = TripleDES.CreateDecryptor(); byte[] Buffer = Convert.FromBase64String(input); decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length)); return decrypted; } catch (Exception ex) { } }



[C#]
Spoiler: RC4 Encode
Code:
public string RC4_Encrypt(string message, string password) { int i = 0; int j = 0; StringBuilder cipher = new StringBuilder(); string returnCipher = string.Empty; int[] sbox = new int[257]; int[] key = new int[257]; int intLength = password.Length; int a = 0; while (a <= 255) { char ctmp = (password.Substring((a % intLength), 1).ToCharArray()[0]); key[a] = Microsoft.VisualBasic.Strings.Asc(ctmp); sbox[a] = a; System.Math.Max(System.Threading.Interlocked.Increment(ref a), a - 1); } int x = 0; int b = 0; while (b <= 255) { x = (x + sbox[b] + key[b]) % 256; int tempSwap = sbox[b]; sbox[b] = sbox[x]; sbox[x] = tempSwap; System.Math.Max(System.Threading.Interlocked.Increment(ref b), b - 1); } a = 1; while (a <= message.Length) { int itmp = 0; i = (i + 1) % 256; j = (j + sbox[i]) % 256; itmp = sbox[i]; sbox[i] = sbox[j]; sbox[j] = itmp; int k = sbox[(sbox[i] + sbox[j]) % 256]; char ctmp = message.Substring(a - 1, 1).ToCharArray()[0]; itmp = Strings.Asc(ctmp); int cipherby = itmp ^ k; cipher.Append(Strings.Chr(cipherby)); System.Math.Max(System.Threading.Interlocked.Increment(ref a), a - 1); } returnCipher = cipher.ToString; cipher.Length = 0; return returnCipher; }



[C#]
Spoiler: Base64 Encode
Code:
public object ConvertToBase64(string Input) { return Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(Input)); }




[C#]
Spoiler: Base64 Decode
Code:
public object ConvertFromBase64(string Input) { byte[] B = System.Convert.FromBase64String(Input); return System.Text.Encoding.UTF8.GetString(B); }



[C#]
Spoiler: Binary Encode
Code:
public string Binary_Encrypt(string input) { string Val = null; string Characters = System.Text.RegularExpressions.Regex.Replace(input, "[^01]", ""); byte[] ByteArray = new byte[(Characters.Length / 8)]; for (int Index = 0; Index <= ByteArray.Length - 1; Index++) { ByteArray[Index] = Convert.ToByte(Characters.Substring(Index * 8, 8), 2); } Val = System.Text.ASCIIEncoding.ASCII.GetString(ByteArray); return Val; }


[C#]
Spoiler: Binary Decode
Code:
public string Binary_Decrypt(string input) { string Val = null; System.Text.StringBuilder Result = new System.Text.StringBuilder(); foreach (byte Character in System.Text.ASCIIEncoding.ASCII.GetBytes(input)) { Result.Append(Convert.ToString(Character, 2).PadLeft(8, "0")); Result.Append(" "); } Val = Result.ToString().Substring(0, Result.ToString().Length - 1); return Val; }



PS: Correct me if i'm wrong in something i wrote =]
Pierce the life fibers with your drill.

Reply

RE: [TUT]What is Encryption? #2
Good thread, I'll have to add some things here.
There is a difference between Encoding, Hash and Encryption.
  • Encoding
    This is a "mod" of the original data without using a special key, therefore you only need the Cipher technique to get the original data.
    Ex: Base64, String Reversal, etc.
  • Hash
    This "mods" the data in such a way that it cannot be "de-hashed" from the output. This is only a 1-way cipher.
    Ex: MD2, MD5, SHA1, etc.
  • Encryption
    This is a "mod" of the original data by using a/multiple special keys, which are needed in order to get back the data even if you have the Encryption technique.
    Ex: RC4, Blowfish, etc.
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: [TUT]What is Encryption? #3
nice tut...ill try to understand it Biggrin

Reply