Rajesh Kumar

Rajesh Kumar

  • 767
  • 1.1k
  • 28k

Encrypted And Decrypted

Mar 15 2023 7:36 AM
static byte[] Encrypt(string simpletext, byte[] key, byte[] iv)
{
    byte[] cipheredtext;
    using (Aes rijAlg = Aes.Create())
    {
        rijAlg.KeySize = 256;
        rijAlg.BlockSize = 128;
        rijAlg.FeedbackSize = 128;
        rijAlg.Padding = PaddingMode.Zeros;
        rijAlg.Key = key;
        rijAlg.IV = iv;

        ICryptoTransform encryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV);
        //ICryptoTransform encryptor = rijAlg.CreateEncryptor(key, iv);
        using (MemoryStream memoryStream = new MemoryStream())
        {
            using (CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
            {
                using (StreamWriter streamWriter = new StreamWriter(cryptoStream))
                {
                    streamWriter.Write(simpletext);
                }

                cipheredtext = memoryStream.ToArray();
            }
        }
    }
    return cipheredtext;
}
static string Decrypt(byte[] cipheredtext, byte[] key, byte[] iv)
{
    string simpletext = String.Empty;
    using (Aes rijAlg = Aes.Create())
    {
        rijAlg.KeySize = 256;
        rijAlg.BlockSize = 128;
        rijAlg.FeedbackSize = 128;
        rijAlg.Padding = PaddingMode.Zeros;
        rijAlg.Key = key;
        rijAlg.IV = iv;


        ICryptoTransform decryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV);
        //ICryptoTransform decryptor = rijAlg.CreateDecryptor(key, iv);
        using (MemoryStream memoryStream = new MemoryStream(cipheredtext))
        {
            using (CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read))
            {
                using (StreamReader streamReader = new StreamReader(cryptoStream))
                {
                    simpletext = streamReader.ReadToEnd();
                }
            }
        }
    }
    return simpletext;
}

Here My Class Encrypt And Decrypt

Encypted Code 

3uJL3A078Cnv7jjeo7chX6udW99oKfOQtljtaHxe0Tb6ysmB1FSssIS4VnibMWBCsNmPRJhqY0+/vJvx87Gdrtkjy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75lJtzH92248MJBeuG6pIbtrw7ZcF3B1veFoWUxYiuexUyiub4QaWrPW6iMaJV+4YHuwCfbojgXBxBCQcYxRgjaYeRTC3+1TuPTTslcJW8Va6O+0iRHnHBFPISyy9XwcyDaYQmtOh6bIgE7A4ANq0g2g3xwqXO505o/c23PTiH+2KdgvtDeBxrMKAHBytwklV8vptzTTZpvcNUyYVugbzblT4ZJb2niYgrn9PJygx/Dnc5GOtpH092YaSPUw+ZEVcXs9z+m473WRNmiZfTSNgPr60JMDa8pDR4xolCKWMSAhEO+xnSiBVU7AvjXfAlBgFQsybx7zVc0kL9OswA9oRXM34kAdTeMRsbBsbqHEWnK883NG8S4d6s533Q1TMA==

If I Decrypeted then show output

I?¦????????????????????????????????????""??????".???????????????????????"??"????????"???????????"???????????????????????????"???????????"????????????????????????????????"????????????????????????????????????????????????"??????????????????????u"?????????????"???????????????????????????????????????????????????????????????????????"???????????????????²?"????????????????????????????????????????????????????"????????????∗???????????????????l???????????????"????????????????????????????????????????????????????????????????????????"???????????????????????????????????h???""???????????"?????????????????????????????????????????????"?????????????????????????????????????????????????????????????????
??????????????????????"?"C????????????+???????????"??????????????????????????????"????????????????????????????????????????????????????????????????????????????????????????????????????????????[??????"????????????"???????????????????y???????????"?????????????????????????????????

Please any suggestions how decrypted code. Please

Thanks & Regards,

Rajesh Kumar


Answers (2)