Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 532489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:24:37+00:00 2026-05-13T09:24:37+00:00

I am trying to encrypt an email body to be stored at database, and

  • 0

I am trying to encrypt an email body to be stored at database, and that to avoid unauthorized person from reading it also to avoid SQL injection attack.

1- What do u think about encrypting the email?

2- Why it does not work? I want to learn encrypting a text anyway.

    SymmetricAlgorithm symAlgo = SymmetricAlgorithm.Create();
    // I will not use the default keys, although I think they are random enough.
    symAlgo.GenerateKey();
    symAlgo.GenerateIV();

    byte[] key = symAlgo.Key;
    byte[] iv = symAlgo.Key;


    ICryptoTransform crypto = symAlgo.CreateEncryptor();
    byte[] block = UtilityMA.StringUtil.ConvertUTF16StringToByteArray(HTMLBody);
    byte[] cipherText = new byte[block.Length + 32];

    crypto.TransformBlock(block, 0, block.Length, cipherText, 0);


    symAlgo.Clear();
    crypto.Dispose();

crypto.TransformBlock fires exception

System.ArgumentException was unhandled by user code
Message=”Value was invalid.”
Source=”mscorlib”

StackTrace:
at System.Security.Cryptography.RijndaelManagedTransform.TransformBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[] outputBuffer, Int32 outputOffset)
at Demo.BLL.Contact.History.SendEmail(String HTMLBody, Int32 Record_Id) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\BLL\BLL\Contact\History.cs:line 35
at _Default.BtnSend_Click(Object sender, EventArgs e) in c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Demos\ContactDemo\Contact.aspx.cs:line 46
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:24:37+00:00Added an answer on May 13, 2026 at 9:24 am

    Try this instead.

    SymmetricAlgorithm symAlgo = SymmetricAlgorithm.Create();
    // I will not use the default keys, although I think they are random enough.
    symAlgo.GenerateKey();
    symAlgo.GenerateIV();
    
    byte[] key = symAlgo.Key;
    byte[] iv = symAlgo.Key;
    
    byte[] cipherText;
    
    using(ICryptoTransform crypto = symAlgo.CreateEncryptor())
    {
      byte[] block = UtilityMA.StringUtil.ConvertUTF16StringToByteArray(HTMLBody);
      cipherText = crypto.TransformFinalBlock(block, 0, block.Length)
    }
    
    symAlgo.Clear();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to encrypt/decrypt one field of SQLite3 database stored in iPhone app.
Have been trying to encrypt an xml file to a string so that I
Hi I am trying to Encrypt a string to invoke a web service from
I'm trying to send an encrypted email with an attachment from PHP, however, my
I am trying to encrypt data that a serializable (xml) class contains. Here is
I am trying to encrypt database columns using a certificate and a symmetric key.
I have been trying to encrypt/ decrypt a sqlite database in my iPhone project.
I'm trying to encrypt some data from python (Google App Engine) and then decrypt
I am trying to decrypt (and later encrypt) an email message (ebXML). The message
I am trying encrypt and decrypt one column in table. My code is like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.