.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

RSACrytoService Provider decrypt each element with seperate key gives Bad Data

Posted By:      Posted Date: August 29, 2010    Points: 0   Category :.NET Framework
I have spent about two days. Here is my code: XmlDocument xmlDoc = new XmlDocument(); xmlDoc.PreserveWhitespace = true; xmlDoc.Load("C:\\test.xml"); CspParameters cspParams = new CspParameters(); cspParams.KeyContainerName = "XML_ENC_RSA_KEY"; RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider(cspParams); CspParameters cspParams2 = new CspParameters(); cspParams2.KeyContainerName = "XML_ENC_RSA_KEY2"; RSACryptoServiceProvider rsaKey2 = new RSACryptoServiceProvider(cspParams2); Encrypt(xmlDoc, "creditcard", "EncryptedElement1", rsaKey, "rsaKey"); Encrypt(xmlDoc, "personal", "EncryptedElement2", rsaKey2, "rsaKey"); This works gerat. Now I want to decrypt the 'creditcard' and 'personal' data elements seperately with 'rsakey' and 'rsakey2' . If do this I get Bad Data error public static void Decrypt(XmlDocument Doc, RSA Alg, string KeyName) { EncryptedXml exml = new EncryptedXml(Doc); exml.AddKeyNameMapping(KeyName, Alg); exml.DecryptDocument(); } This gives bad data since the file has been encrypted with two different keys. So I tried something like this. But I don't know how to decrypt each data element seperately.  Can someone please help? public static void DecryptElement(string ElementToEncrypt, RSA Alg, string KeyName) {

View Complete Post

More Related Resource Links

Need Oracle Data Provider .CS File for Oracle 10g Database connection !



I need a 'Wrapper.cs' file which takes care of the Database connection ( Oracle 10g) where

i can just call the method with my SQL Query


Gridview1.DataSource = SampleWrapper.ExecuteDatatable("THE SQL QUERY");


Plz Post the link if there is any open source !    

ADO.NET: Building a Custom Data Provider for Use with the .NET Data Access Framework


The System.Data.dll assembly in the .NET Framework contains namespaces whose base classes can be used to create custom data providers. These namespaces also define a number of data access interfaces and base classes that let developers create data providers that will interoperate with other custom providers. Using the ADO.NET classes Connection, Command, DataReader, and DataAdapter, writing a provider is easier than writing one for OLE DB. This article explains these classes and their implementation, and how they can be used to write a variety of different kinds of data providers.

Bob Beauchemin

MSDN Magazine December 2001

Trying to run a stored procedure from vb code with oracle data provider.



Here is my SP:

create or replace
 Open p_getuserssignon_recordset1 for
 SELECT Distinct(Userid), UserPassword, SecurityLevel, ActiveStatus
WHERE substr(UserId,1,2) <> vUid
Order By UserId;

I would like to run this SP from code and fill a gridview with the result. 

I am not sure how to go about this, as I have found several different examples, other than the one I  think I need.

I am using the oracle data provider and I have an input parameter (vUid, which will equal "zz").

First question. When filling a gridview with a result set from a stored procedure should the recordset OUT be defined as a REFCURSOR (like i did above)? 


Do you have example code as to how to execute the SP and fill a gridview?  I keep trying different variations of code i've found on the internet without any success other than getting more confused.

(I am using VS 2005, VB).

Thank you.



Server 2008 R2 -> Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error mess


So I am using the aspnet_regiis.exe tool to encrypt sections of the web.config in my asp.net applications and services.  I have done this for years successfully on Windows Server 2003 (IIS 6).  However I just moved some apps over to Windows Server 2008 R2 (with IIS 7.5) and I am now receiving the following error at runtime:

"Server was unable to process request. ---> Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: Bad Data."

Now I am quite familiar with this process and am stumped at what I have missed this time around.  I have done ALL of the following which typically suffices for the process on the server. PLEASE READ ALL AND DO NOT PROVIDE RESPONSES OR LINKS FOR THINGS I HAVE ALREADY DONE Thanks!!  Wink

  1. Imported the keys to the server using aspnet_regiis -pi  Result: Success
  2. Given FULL permission (using -full switch) using aspnet_regiis -pa to ALL of the following accounts  Result: Success
    1. .Net SqlClient Data Provider connecting as sa

      I recently changed the sa password on a SQL 2005 std sp3 default instance. I now see .Net SQL data provider connecting with sa login from an app server. From a trace I see: Application name: .Net Sql Client data provider NTUserName: sqluser LoginName: sa HostName: app server name LoginSID: SID for sa SessionLoginName: ssd\sqluser Sqluser is a sql server logon that is not sa. SSD\sqluser is local admin on app server and is not sa on SQL SERVER and is not in builtin/administrators either. I thought an existing session may explain it but both the app server and sql server have been restarted since the sa p/w change. Could I be misinterpreting the Profiler output? Any ideas?

mysql data source provider - mysql connector/net

Dear All, I having problem installing mysql connector/net 6.2.3 on my vsd 2010 because the installed went smoothly but when Im trying to use the mysql on data source provider, I cant see it on the list and when try to install/change the connector the visual studio integreation has an x mark meaning to say it was not installed on my vsd2010.  Thanks.

#BIND two seperate data items into one label

Hey people!I have a simple question.. but for the life of me cannot figure it out. I have two fields in my database (firstname and lastname)I have a formview, and I filter the results and I get two labels - one with firstname and one with lastname. I want to put the FIRSTNAME and LASTNAME together in one label but I am stuck lol. <asp:label id="label1" runat="server" SkinID="profilepropertylabel" Text='<%BIND ("Firstname") & BIND("Lastname") %>' />It only gives me the last name when I do that. Help?

Login failed for user 'sa'. (.Net SqlClient Data Provider)

Hi,     I am able to login using windows Authentication to my DB server. But when I am trying using Sql server authentication "sa" then following error is coming:   =================================== Cannot connect to .. =================================== Login failed for user 'sa'. (.Net SqlClient Data Provider) ------------------------------ For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476 ------------------------------ Server Name: . Error Number: 18456 Severity: 14 State: 1 Line Number: 65536 ------------------------------ Program Location:    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)    at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)    at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) &

How to Decrypt rc4 data by using Cryptography namespace?

I have encrypt a string by using CALG_RC4 Algorithm in C++ on the client side. I want to Decrypt it in C# on the server side. I can do the mession by using RC2 Algorithm. Because there are classes such as DESCryptoServiceProvider ,RC2CryptoServiceProvider in the namespace Cryptography. But there is any RC4CryptoServiceProvider class. So I don't know how to do it. I appreciate your view.

Lookup Column Data on seperate Subsite


Is there a way to make a look up reference a column on a seperate subsite?  I was thinking I could do it with BCS but I seem to be having an issue setting up a MOSS 2010 list as a source.

Basically I have SubSiteA with a list that includes some catalog information for systems and SubSiteB is a Doc Center that contains various atricles about the systems. I want to have one column in SubSiteB reference a Column from SubSiteA to use as metadata for search/filter purposes.


Any thoughts?  Thanks

Enterprise Applications Specialist

System.InvalidOperationException: Internal .Net Framework Data Provider error 12.



I have created an application in which there are few forms. Each form has fields which are linked to a backend table/tables. My application is supposed to be accessed by multiple users concurrently. I ran a test where I created a class file in windows application and i ran a for loop in it to call the url of my application. I wanted to test the effect of firing around 200 queries to my query engine.

The test code is :

namespace MachineGun


static class Program


/// <summary>

/// The main entry point for the application.

/// </summary>


Failed to find or load the registered .Net Framework Data Provider.




I am using enterprise library 5.0,vs.net 2008,oracle 9i,odp.net version.

In machine.config I added the line below in

<add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory , Oracle.DataAccess, Version=, Culture=neutral, PublicKeyToken=89b483f429c47342"/>


DbProviderFactory pf = DbProviderFactories.GetFactory("Oracle.DataAcess.Client");

above line is throwing an error.

System.Configuration.ConfigurationErrorsException was unhandled by user code

Message="Failed to find or load the registered .Net Framework Data Provider."


BareMessage="Failed to find or load the registered .Net Framework Data Provider."



at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)

at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)

at testweb2008.Classes.test..ctor(String strKey) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\testweb2008\testweb2008\Classes\test.cs:line 30

at testweb2008._Default.Page_Load(Object sender

Cannot generate SSPI context. (.Net SqlClient Data Provider)


I have upgraded SQL SERVER 2000 standard edition server to SQL server 2008 with SP1 standard edition. No errors noticed. OS is Windows server 2003 with sp2, Service accounts are configured using domain user account, and mixed mode authentication is enabled.

Both windows and SQL authentications are working fine from the local (server), able to access all SQL server resources.

Server is accessible remotely using SQL authentication, but unable to connect with windows authentication, though user has local admin and SQL admin rights on the server.

Let me know any solutions for this. Appreciate your support

SSAS 2008R2 - Enable to process a database using Oracle OraOLEDB data provider



I've created a data source in BIDS using provider OraOLEDB.Oracle.1. The Oracle database is 10gR2. The client installed on my computer is 10gR2. The connexion is OK when I use Test Connexion in BIDS.

In the data source view I created a very simple query: select * from user_objects. All is fine, the fields are correctly defined.

I've created a dimension based on this query with object_id as the key.

I've deployed the solution to the server. All is working fine for the moment.

But when I process the dimension I get a dozen of error messages like (sorry error messages are in french) :

"Erreur OLE DB : Erreur OLE DB ou ODBC : Syntax error near 'OraOLEDB.Oracle.1' on line 8; 42000."

Erreurs dans le moteur de stockage OLAP : Une erreur s'est produite lors du traitement de dimension portant l'ID 'Test' et le nom 'Test'.

Erreurs dans le moteur de stockage OLAP : Une erreur s'est produite lors du traitement de l'attribut 'SUBOBJECT NAME' de la dimension 'Test' de la base de données 'CTRL_DOMAINES'.

Serveur : L'opération a été annulée.

Erreur OLE DB : Erreur OLE DB ou ODBC : Syntax error near 'OraOLEDB.O

Unable to connect with IBM DB2 using IBM DB2 .NET Data Provider 9.1.5 with ADO Destination Component


As we are passing through critical phase of the project and we are facing following issues which need to be resolved.Please help on this.

Currently we are transferring Data from SQL Server to DB2 using SSIS (SQL Server 2008).The IBM DB2 version is DB2 ESE 9.1 Fix Pack 5 on Linux 4.8.

1] Unable to connect with IBM DB2 using IBM DB2 .NET Data Provider 9.1.5 in SSIS 2008 at run time (although the connection is tested successfully with IBM DB2 using IBM DB2 .NET Data Provider 9.1.5 in SSIS 2008) and the error is

"[ADO NET Destination [6096]] Error: An exception has occurred during data insertion, the message returned from the provider is: Object reference not set to an instance of an object. "

I tried to use CozyRock DB2 Destination component instead of ADO destinatoin Component then i am able to use IBM DB2 .NET provider at run time.

Also i tested connection successfully using IBM DB2 .NET Data Provider 9.1.5

missing oracle provider for ole db in data link properties of adodc1 in my vb with already installed


missing oracle provider for ole db in data link properties of adodc1 in my vb with already installed oracle client...

please help how to have this "oracle provider for ole db"

Length of the data to decrypt is invalid. tripleDES c#


Hey there.. i am trying to make an Encrypt and Decrypt method...

When i try to encrypt it goes fine.. but when i right after try to decrypt it i get an:

"Length of the data to decrypt is invalid" error...

the error occours when i try to run the code FlushFinalBlock();

here is my code:

        public string Encrypt(string plainText)
            UTF8Encoding utf8Encoder = new UTF8Encoding();
            byte[] inputInBytes = utf8Encoder.GetBytes(plainText);
            TripleDESCryptoServiceProvider tdesProvider = new TripleDESCryptoServiceProvider();
            ICryptoTransform cryptoTransform = tdesProvider.CreateEncryptor(symKey, IVKey);
            MemoryStream encryptedStream = new MemoryStream();
            CryptoStream cryptStream = new CryptoStream(encryptedStream, cryptoTransform, CryptoStreamMode.Write);

            cryptStream.Write(inputInBytes, 0, inputInBytes.Length);
            encryptedStream.Position = 0;
            byte[] result = new byte[encryptedStream.Length];
            encryptedStream.Read(result, 0, (int)encryptedStream.Length);
            return utf8Encoder.GetString(result);

        public string Decrypt(string encryptedString)
            UTF8Encoding utf8Encoder =
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend