Home > bad data > bad data error asp.net

Bad Data Error Asp.net

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up “Bad Data” CryptographicException up vote 5 down vote favorite 2 First, I have only written the code below for academic purposes. The reason I say this is because I am not putting this in a production environment, and therefor am "bypassing" some of the overhead that I would need to do if I was, I simply need to be able to encrypt/decrypt a string using the code below. I was able to do it a few time, but for some reason, I started receiving "CryptographicException Bad Data" and am not sure what might be causing the problem. private string RSAEncrypt(string value) { byte[] encryptedData = Encoding.Unicode.GetBytes(value); CspParameters cspParams = new CspParameters(); cspParams.KeyContainerName = _rsaContainerName; using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048,cspParams)) { encryptedData = RSA.Encrypt(encryptedData, false); return Convert.ToBase64String(encryptedData); } } private string RSADecrypt(string value) { byte[] encryptedData = Encoding.Unicode.GetBytes(value); CspParameters cspParams = new CspParameters(); cspParams.KeyContainerName = _rsaContainerName; using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048,cspParams)) { encryptedData = RSA.Decrypt(encryptedData,false); return Convert.ToBase64String(encryptedData); } } It is only throwing this exception on the RSADecrypt call. Any ideas? I read somewhere it might have to do with the expected size of encryptedData that is passed into RSA.Decrypt. Thanks } c# encryption cryptography rsa share|improve this question edited Mar 11 '12 at 23:48 asked Mar 11 '12 at 23:17 TheJediCowboy 2,1111672130 Uh, how are you passing the keys between the methods? –Maarten Bodewes Mar 12 '12 at 19:50 add a comment| 3 Answers 3 active oldest votes up vote 10 down vote accepted Convert the plaintext back and forth using a string-encoding (i.e. Encoding.Unicode). Convert the encrypted data back and

ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/Web Forms/Error :Bad Data Error :Bad Data [Answered]RSS 8 replies Last post Apr 29, 2013 09:31 AM by Mohammed Saleh ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads Unresolved Threads Support Options Advanced Search Related Links GuidanceSamplesVideos Reply Mohammed Sal... Member 54 Points 439 Posts Error :Bad Data http://stackoverflow.com/questions/9659898/bad-data-cryptographicexception Apr 25, 2013 04:19 AM|Mohammed Saleh|LINK Public Function Readconnectionstring() As String Try Dim secretkey As String = "Employee" Dim sr As New StreamReader("C:\connection\tcon.txt") Dim Server As String = sr.ReadLine() Dim database As String = sr.ReadLine() Dim userid As String = sr.ReadLine() Dim password As String = sr.ReadLine() sr.Close() http://forums.asp.net/t/1901564.aspx?Error+Bad+Data Dim ds As String = Decryption(Server, secretkey) Dim db As String = Decryption(database, secretkey) Dim uid As String = Decryption(userid, secretkey) Dim pass As String = Decryption(password, secretkey) cons = "Data Source =" & ds & "; DataBase =" & db & "; User Id =" & uid & "; Password =" & pass & ";" Catch ex As Exception MsgBox(ex.Message) End Try Return cons End Function Private Function createdes(ByVal key As String) As TripleDES Dim md5 As MD5 = New MD5CryptoServiceProvider() Dim des As TripleDES = New TripleDESCryptoServiceProvider() des.Key = md5.ComputeHash(Encoding.Unicode.GetBytes(key)) des.IV = New Byte(des.BlockSize \ 8 - 1) {} Return des End Function Private Function Decryption(ByVal cyphertext As String, ByVal key As String) As String Dim b As Byte() = Convert.FromBase64String(cyphertext) Dim des As TripleDES = createdes(key) Dim ct As ICryptoTransform = des.CreateDecryptor() Dim output As Byte() = ct.TransformFinalBlock(b, 0, b.Length)->

& solutions from https://bytes.com/topic/asp-net/answers/316682-bad-data-error a community of 418,436 IT Pros & Developers. It's http://community.instantasp.co.uk/1756/Bad-Data-Error-SystemSecurityCryptographyCryptographic quick & easy. Bad Data Error P: n/a ERamirez I downloaded the Portal Starter Kit of http://asp.net and started adding a few modules. All debuggin localy worked fine but once I put it onto a Windos bad data Server 2003 I keep getting the following error. Bad Data. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Security.Cryptography.CryptographicExceptio n: bad data error Bad Data. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [CryptographicException: Bad Data. ] System.Security.Cryptography.CryptoAPITransform._D ecryptData(IntPtr hKey, Byte[] rgb, Int32 ib, Int32 cb, Boolean fDone) +0 System.Security.Cryptography.CryptoAPITransform.Tr ansformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) +805 System.Security.Cryptography.CryptoStream.FlushFin alBlock() +40 System.Web.Configuration.MachineKey.EncryptOrDecry ptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length) +139 System.Web.Security.FormsAuthentication.Decrypt(St ring encryptedTicket) +114 ASPNET.StarterKit.Portal.Global.Application_Authen ticateRequest(Object sender, EventArgs e) +591 System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute() +60 System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +87 -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573 The code where I believe this orignates from is the Cookie encryption which looks like the following: Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs) If Request.IsAuthenticated = True

Active Directory FOR INSTANTFORUM AND INSTANTKB Start your free trial Live Demos Our Licensing Purchase Support Subscriptions Your Cart Need help or require further information? Email us on sales@instantasp.co.uk or call us on +44 ( 0 ) 1565 832 827 between 7.30am and 5.30pm UTC. Getting Started Knowledgebase Documentation Community Forums Submit a Support Ticket Need help or require further assistance? Email us on sales@instantasp.co.uk or call us on +44 ( 0 ) 1565 832 827 between 7.30am and 5.30pm UTC. Forums Blog User Comments Contact Us On Facebook On Twitter On Google On LinkedIn If you like InstantASP, help us spread the word Tweet about InstantASP Like InstantASP on Facebook +1 InstantASP on Google My.InstantASP Edit Profile My Downloads My Tickets My Support Plans Order History Welcome Guest Login or Create an Account Back InstantASP Forums Register Login Narrow your search by forum Home » InstantKB » General Discussion » Bad Data Error - System.Security.Cryptography.Cryptographic Bad Data Error - System.Security.Cryptography.Cryptographic FOLLOW (0) J 0 J Jan Bob Jan Bob posted 12 Years Ago Ryan, do you know why one workstation would always be getting this error when loading InstantKB ? I even rebooted, didnt help. Rebooted the db server, didnt help. Should I try rebooting the webserver (where instantkb is running) ? Is there a more gracefull solution ? All other workstations load InstantKB just fine,Server Error in '/InstantKB' Application. --------------------------------------------------------------------------------Bad Data. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Detai

 

Related content

bad data error in c#

Bad Data Error In C table id toc tbody tr td div id toctitle Contents div ul li a href C Des Decrypt Bad Data a li li a href The Stub Received Bad Data C a li li a href Data Error Event In Datagridview C a li li a href System security cryptography cryptographicexception Bad Data C a li ul td tr tbody table p here for a quick overview of the site Help relatedl Center Detailed answers to any questions you might p h id C Des Decrypt Bad Data p have Meta Discuss the workings and

bad data crc error cannot get kernel image

Bad Data Crc Error Cannot Get Kernel Image p Hi I have burned u-boot uImage and qtopia M in my nand While booting it shows me this and gets stuck at the end saying Bad Data CRC ERROR can't get kernel image This is the output relatedl on minicom Please let me know the solution to this problem U-Boot -mini May - I C ready DRAM MB Flash MB NAND Bad block table not found for chip Bad block table not found for chip MiB Found Environment offset in OOB USB S C USB Deviced In serial Out serial Err

bad data error

Bad Data Error table id toc tbody tr td div id toctitle Contents div ul li a href Examples Of Bad Data a li li a href Bad Data Band a li ul td tr tbody table p here for a quick overview of the site relatedl Help Center Detailed answers to any questions you cryptostream bad data error might have Meta Discuss the workings and policies of this decstream flushfinalblock bad data site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or cryptostream read bad data posting ads with us Stack Overflow

bad data crc error

Bad Data Crc Error table id toc tbody tr td div id toctitle Contents div ul li a href U Boot Crc Error a li ul td tr tbody table p Hi I have burned u-boot uImage and qtopia M in my nand While booting it shows me this and gets stuck at the end saying Bad Data CRC ERROR can't get kernel image This is the output on minicom Please let me know relatedl the solution to this problem U-Boot -mini May - verifying checksum bad data crc u boot I C ready DRAM MB Flash MB NAND Bad

cryptostream bad data error

Cryptostream Bad Data Error table id toc tbody tr td div id toctitle Contents div ul li a href Bad Data Exception Java a li li a href Vb net Flushfinalblock Bad Data a li li a href C Rsa Decrypt Bad Data a li ul td tr tbody table p here for a quick overview of relatedl the site Help Center Detailed answers to any system security cryptography cryptographicexception bad data c questions you might have Meta Discuss the workings and policies bad data cryptographicexception c of this site About Us Learn more about Stack Overflow the company Business

error bad data line

Error Bad Data Line table id toc tbody tr td div id toctitle Contents div ul li a href Gnuplot Bad Data On Line a li li a href Gnuplot Csv a li li a href Gnuplot Using a li ul td tr tbody table p p p p p p p p

error while writing encrypted data stream

Error While Writing Encrypted Data Stream table id toc tbody tr td div id toctitle Contents div ul li a href Cryptostream Flushfinalblock Bad Data a li li a href Bad Data Exception C a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have relatedl Meta Discuss the workings and policies of this site system security cryptography cryptographicexception bad data c About Us Learn more about Stack Overflow the company Business Learn more about bad data exception java hiring developers or posting ads with

flushfinalblock bad data error

Flushfinalblock Bad Data Error table id toc tbody tr td div id toctitle Contents div ul li a href Cryptostream Flushfinalblock Bad Data a li li a href Bad Data Exception Java a li ul td tr tbody table p here for a quick overview of the relatedl site Help Center Detailed answers to any questions system security cryptography cryptographicexception bad data c you might have Meta Discuss the workings and policies of p h id Cryptostream Flushfinalblock Bad Data p this site About Us Learn more about Stack Overflow the company Business Learn more about hiring vb net flushfinalblock