find and solve || findandsolve.com
Please wait.....

Welcome back.






Before Read Terms of use

AES algorithm steps and AES256 Implementation in c# or Decrypt Salseforce Encrypted value in asp.net C#


 Represents the abstract base class from which all implementations of the Advanced Encryption Standard (AES) must inherit.

public abstract class Aes : System.Security.Cryptography.SymmetricAlgorithm


Derived
System.Security.Cryptography.AesCng
System.Security.Cryptography.AesCryptoServiceProvider
System.Security.Cryptography.AesManaged



 public static byte[] Encrypted()
        {
            // Check arguments.
            string plainText = "FindAndSolveDecrypted Value";
            string key = "DFEA254COac237A27EF839AFC0E";
            //convert string key to byte as given below
            byte[] Key = Encoding.UTF8.GetBytes(key);
            byte[] IV = Encoding.ASCII.GetBytes("FindSolve 123");
            byte[] encrypted;
            // Create an Aes object
            // with the specified key and IV.
            using (Aes aesAlg = Aes.Create())
            {
                aesAlg.Key = Key;
                aesAlg.IV = IV;
                // Create an encryptor to perform the stream transform.
                ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
                // Create the streams used for encryption.
                using (MemoryStream msEncrypt = new MemoryStream())
                {
                    using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                    {
                        using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
                        {
                            //Write all data to the stream.
                            swEncrypt.Write(plainText);
                        }
                        encrypted = msEncrypt.ToArray();
                    }
                }
            }
            // Return the encrypted bytes from the memory stream.
            return encrypted;
        }

  public static string DecryptString(string QUERY)
        {
           
            string key = "DFEA254COac237A27EF839AFC0E";
            byte[] iv = Encoding.ASCII.GetBytes("FindSolve 123");
            byte[] buffer = Convert.FromBase64String(QUERY);
            using (Aes aes = Aes.Create())
            {
                aes.Key = Encoding.UTF8.GetBytes(key);
                aes.IV = iv;
                ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
                using (MemoryStream memoryStream = new MemoryStream(buffer))
                {
                    using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, decryptor, CryptoStreamMode.Read))
                    {
                        using (StreamReader streamReader = new StreamReader((Stream)cryptoStream))
                        {
                            return streamReader.ReadToEnd();
                        }
                    }
                }
            }
        }

Sundar  Neupane

Sundar Neupane

I like working on projects with a team that cares about creating beautiful and usable interfaces.

Comments



Report Response