전자 메일 본문을 암호화하여 데이터베이스에 저장하려고하고 있으며 권한이없는 사용자도 SQL 주입 공격을 피하기 위해 읽지 않습니다.대칭 알고리즘 예외
1- 이메일 암호화에 대해 어떻게 생각하십니까?
2 왜 작동하지 않습니까? 어쨌든 텍스트를 암호화하는 법을 배우고 싶습니다.
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 화재 예외
System.ArgumentException는 메시지 = 사용자 코드에 의해 처리되지 않은했다 "값이 잘못되었습니다." 자료 = "mscorlib에"
스택 트레이스 : System.Security.Cryptography.RijndaelManagedTransform.TransformBlock (바이트 [] INPUTBUFFER, inputOffset INT32, INT32 inputCount 바이트 [] outputBuffer, INT32를 outputOffset) 에서 Demo.BLL.Contact에서 C : \ Documents and Settings \ Administrator \ My Documents \ Visual Studio 2008 \ Projects \ BLL \ BLL \ Contact \ History.cs에있는 .History.SendEmail (String HTMLBody, Int32 Record_Id) : _Default.BtnSend_Click에서 35 (Object sender , EventArgs e) : System.Web.UI.WebControls.Button.OnClick (EventArgs)에서 c : \ Documents and Settings \ Administrator \ My Documents \ Visual Studio 2008 \ Projects \ Demos \ ContactDemo \ Contact.aspx.cs : 줄 46 e) at System.Web.UI.WebControls.Button.RaisePostBackEven t (문자열 eventArgument) System.Web.UI.Page.RaisePostBackEvent에서 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (문자열 eventArgument) (IPostBackEventHandler sourceControl, 문자열 eventArgument) 에서 에서