Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

[C#]Encryptions Thread(RSA,XOR,RC4,Etc)

All these encryptions are ported off the ones posted in Prototypes thread.
I simply ported them to C#:

DES:
Code
public string DES_Encrypt(string input, string pass)
        {
            System.Security.Cryptography.DESCryptoServiceProvider DES = new System.Security.Cryptography.DESCryptoServiceProvider();
            System.Security.Cryptography.MD5CryptoServiceProvider Hash_DES = new System.Security.Cryptography.MD5CryptoServiceProvider();
            string encrypted = "";
            try
            {
                byte[] hash = new byte[8];
                byte[] temp = Hash_DES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass));
                Array.Copy(temp, 0, hash, 0, 8);
                DES.Key = hash;
                DES.Mode = System.Security.Cryptography.CipherMode.ECB;
                System.Security.Cryptography.ICryptoTransform DESEncrypter = DES.CreateEncryptor();
                byte[] Buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(input);
                encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length));
                return encrypted;
            }
            catch (Exception ex)
            {
            }
            return encrypted;
        }
        public string DES_Decrypt(string input, string pass)
        {
            System.Security.Cryptography.DESCryptoServiceProvider DES = new System.Security.Cryptography.DESCryptoServiceProvider();
            System.Security.Cryptography.MD5CryptoServiceProvider Hash_DES = new System.Security.Cryptography.MD5CryptoServiceProvider();
            string decrypted = "";
            try
            {
                byte[] hash = new byte[8];
                byte[] temp = Hash_DES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass));
                Array.Copy(temp, 0, hash, 0, 8);
                DES.Key = hash;
                DES.Mode = System.Security.Cryptography.CipherMode.ECB;
                System.Security.Cryptography.ICryptoTransform DESDecrypter = DES.CreateDecryptor();
                byte[] Buffer = Convert.FromBase64String(input);
                decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length));
                return decrypted;
            }
            catch (Exception ex)
            {
            }
            return decrypted;
        }

AES:
Code
public string AES_Encrypt(string input, string pass)
        {
            System.Security.Cryptography.RijndaelManaged AES = new System.Security.Cryptography.RijndaelManaged();
            System.Security.Cryptography.MD5CryptoServiceProvider Hash_AES = new System.Security.Cryptography.MD5CryptoServiceProvider();
            string encrypted = "";
            try
            {
                byte[] hash = new byte[32];
                byte[] temp = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass));
                Array.Copy(temp, 0, hash, 0, 16);
                Array.Copy(temp, 0, hash, 15, 16);
                AES.Key = hash;
                AES.Mode = System.Security.Cryptography.CipherMode.ECB;
                System.Security.Cryptography.ICryptoTransform DESEncrypter = AES.CreateEncryptor();
                byte[] Buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(input);
                encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length));
                return encrypted;
            }
            catch (Exception ex)
            {
            }
            return encrypted;
        }
        public string AES_Decrypt(string input, string pass)
        {
            System.Security.Cryptography.RijndaelManaged AES = new System.Security.Cryptography.RijndaelManaged();
            System.Security.Cryptography.MD5CryptoServiceProvider Hash_AES = new System.Security.Cryptography.MD5CryptoServiceProvider();
            string decrypted = "";
            try
            {
                byte[] hash = new byte[32];
                byte[] temp = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass));
                Array.Copy(temp, 0, hash, 0, 16);
                Array.Copy(temp, 0, hash, 15, 16);
                AES.Key = hash;
                AES.Mode = System.Security.Cryptography.CipherMode.ECB;
                System.Security.Cryptography.ICryptoTransform DESDecrypter = AES.CreateDecryptor();
                byte[] Buffer = Convert.FromBase64String(input);
                decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length));
                return decrypted;
            }
            catch (Exception ex)
            {
            }
            return decrypted;
        }

RSA:

Code
public string RSA_Encrypt(string Input)
        {
            System.Security.Cryptography.CspParameters cp = new System.Security.Cryptography.CspParameters();
            cp.Flags = System.Security.Cryptography.CspProviderFlags.UseMachineKeyStore;
            cp.KeyContainerName = "Keys";
            System.Security.Cryptography.RSACryptoServiceProvider RSA = new System.Security.Cryptography.RSACryptoServiceProvider(cp);

            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(Input);
            byte[] encrypted = RSA.Encrypt(buffer, true);
            return Convert.ToBase64String(encrypted);
        }
        public string RSA_Decrypt(string Input)
        {
            System.Security.Cryptography.CspParameters cp = new System.Security.Cryptography.CspParameters();
            cp.Flags = System.Security.Cryptography.CspProviderFlags.UseMachineKeyStore;
            cp.KeyContainerName = "Keys";
            System.Security.Cryptography.RSACryptoServiceProvider RSA = new System.Security.Cryptography.RSACryptoServiceProvider(cp);
            byte[] buffer = Convert.FromBase64String(Input);
            byte[] decrypted = RSA.Decrypt(buffer, true);
            return System.Text.Encoding.UTF8.GetString(decrypted);
        }

Enjoy!
You should put it into a class library so people can download and import the .dll and use functions such as rc4(string data, string key) and provide snippets.

Good release but an encryption library would be helpful.
Could you please provide a link to Prototypes thread, as that is not his username, thank you.
[Image: G9HkL.gif]
https://hackforums.net/showthread.php?ti...encryption


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by putnik1313Jun 21, 2025 08:59 PM 12 437 Jun 21, 2025 08:59 PM
Last Post: Goods
by putnik1313May 26, 2025 03:04 PM 6 226 May 26, 2025 03:04 PM
Last Post: putnik1313
[Python] by MiguelSanchezJun 5, 2022 10:47 PM 5 308 Jun 5, 2022 10:47 PM
Last Post: MiguelSanchez