.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

Decrypt the value

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :

How to decrypt the following value

Front End is VB 6.0 and Backend is SQL Server 2005.  Through front end the data is encryting and inserting into the database. I don't know which algorithm is used inside the VB application.Now i want to decrypt the data through sql server 2005.

PRODUCTID: G/boja2sL6juk30d8YSaF0F5dWiQ6hr/ltz6E6+HY8jKkHtbFTHREnX0x8DE3wX1gDBLw7zEPTI5dKYwkil2EC7RaLDENZ9gmK0r3gYGH90=

please give me the solution?

View Complete Post

More Related Resource Links

How to Encrypt and Decrypt a Password using SQLSERVER 2005?(Video)

Encypt and Decrypt a Password using SQLSERVER 2005(Video)

Is it possible to write the same encrypt and decrypt method that in MembershipProvider


Hi, I am very confused about encrypting and decrypting password.

What I did is that, I am using a class that extends SqlMembershipProvider, and when I need to encrypt a password, just called base.EncryptPassword() method to do so.

But still, I did not get to know how things are done here, and I really would like to know its codes.

Can anyone provide the code for me please?


Problem with decrypt password


hello everyone:



I encryped password to the binary variable in sql server with this code:

 DataClasses1DataContext db = new DataClasses1DataContext();
            var info = new passdefine();
            info.username = TextBox1.Text;
            string strcry = TextBox2.Text;
            byte[] bt = new byte[strcry.Length];
            bt = System.Text.Encoding.UTF8.GetBytes(strcry);
            RSACryptoServiceProvider RSA1 =new RSACryptoServiceProvider();

            bt = RSA1.Encrypt(bt,false);

            info.password = bt;


And it worked properly but when Want to decrypt it , I get this error:BAD DATA.  

And I use this code:

DataClasses1DataContext db=new DataClasses1DataContext();
            var info = from m in db.passdefines where m.username == TextBox1.Text select m;
            foreach (var item in info)

                byte[] bt = new byte[item.password.length];
                RSACryptoServiceProvider RSA1 = new RSACryptoServiceProvider();
                bt = RSA1.Decrypt(item.password.ToArray(), false);
                string pass = System.Text.Encoding.UTF8.GetString(bt);

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. RSACrytoService Provider decrypt each element with seperate key gives Bad Data

      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) {

Question about RSA Decrypt using private key

Hello,      I am doing a project to communiate with a bank. I send a message which was sign by my private key to the bank and get a response from the bank. The message like below: PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iR0JLIj8+CjxtZXNzYWdlIG1ldGhvZD0iZXJyb3IiIHR5cGU9InJlc3BvbnNlIj4KICAgIDxkYXRlPjIwMTAwNTI4PC9kYXRlPgogICAgPHRpbWU+MTEwMzQ1PC90aW1lPgogICAgPHJldENvZGU+QVVUSDBFSTwvcmV0Q29kZT4KICAgIDxjb21tZW50UmVzPuacquW8gOWNoTwvY29tbWVudFJlcz4KPC9tZXNzYWdlPgo= Then I try to decrypt the message. The code like below:        public static string ParsePayment(HttpRequest request)     {         string CertificatePW = "123456";         string prikey_path = HttpContext.Current.Server.MapPath("~/App_Data") + "\\certificate\\test.pfx";         return CerRSADecrypt(Convert.FromBase64String(aa), prikey_path, CertificatePW);          }         public static string CerRSADecrypt(byte[] DataToDecrypt, string prikey_path, string CertificatePW)     {                        &nbs

SSIS Package Protection Level Errors - decrypt protected XML node "DTS:Password" with error 0x800900

Error 7 Error loading GetData.dtsx: Failed to decrypt protected XML node "DTS:Password" with error 0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available.   c:\Packages\GetData.dtsx 1 1  Error 8 Validation error. Data Flow Task: OLEDB Source [5310]: The AcquireConnection method call to the connection manager "SourceServer" failed with error code 0xC0202009. GetData.dtsx 0 0 Environment I need to execute - BIDSHave Solution, with files linked with VSS. When I click on package, aforesaid errors show up and package opens in designed.Protection Level : Encrypt Sesitive with User KeyThis means it'd run only on machine and by user where and who created respectively.So I changed it to Encrypt Sesitive with Passoword and provided Passoword. No luckSo I changed it to Do not save sensitive, as anyways in the connection manager, it has Expression saying @Variablename (with appropriate correct syntax), and variable is mapped to config file. I tired with Config file and also by hardcoding the value in the connection manager's connection string after removing the variable name, also tried by hardcoding value in variable value and disabling config file.Nothing works. I read 3 threads discussing this issue by othe

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.

How to encrypt and decrypt stored procedures?

I encrypt my procedures using with encryption clause, but I do not how to decrypt again.    Is there a command or utility for encrypt and decrypt in Sql 2000? How about Sql 2005? Thanks Haydee

How can i decrypt an encrypted stored procedure?

hi there,i'm having a problem on how to decrypt an encrypted stored procedure on SQL Server 2008i've tried asking my workmates but they mentioned that they're forgotten the basic syntax to decryptmost of the query i can find are for sql server 2005.. are they usable to sql server 2008?i found this but it doesn't seem to helpCreate Procedure Decryptsp2K (@objName varchar(50)) AS -- INPUT: object name (stored procedure, view or trigger) DECLARE @a nvarchar(4000), @b nvarchar(4000), @c nvarchar(4000), @d nvarchar(4000), @i int, @t bigint --get encrypted data SET @a=(SELECT ctext FROM syscomments WHERE id = object_id(@objName)) SET @b='ALTER PROCEDURE '+ @objName +' WITH ENCRYPTION AS '+REPLICATE('-', 4000-62) EXECUTE (@b) --get encrypted bogus SP SET @c=(SELECT ctext FROM syscomments WHERE id = object_id(@objName)) SET @b='CREATE PROCEDURE '+ @objName +' WITH ENCRYPTION AS '+REPLICATE('-', 4000-62) --start counter SET @i=1 --fill temporary variable SET @d = replicate(N'A', (datalength(@a) / 2)) --loop WHILE @i<=datalength(@a)/2 BEGIN --xor original+bogus+bogus encrypted SET @d = stuff(@d, @i, 1, NCHAR(UNICODE(substring(@a, @i, 1)) ^ (UNICODE(substring(@b, @i, 1)) ^ UNICODE(substring(@c, @i, 1))))) SET @i=@i+1 END --drop original SP EXECUTE ('drop PROCEDURE '+ @objName) --remove encryption --try to p

Failed to decrypt protected XML node "DTS:Password" with DontSaveSensitve Checked



I have been researching and researching this.  First, I have all my packages all have the protection level set to DontSaveSensitive.  Second, all my passwords are stored in a config file.  This config file location is stored in an env variable.  The packages are all calling the config files from package configurations.

If I do the development on our dev server I dont' have a problem. As soon as I go to our test box, I get the error or if another person accesses it and tries to run it they get the error.

I have no idea to fix this.  The only solution I have found anywhere is to change the protectionlevel.  Changing it to rely on server gives me more error messages.  I honestly don't remember having this issue before now.

please help!



Encrypt in PHP, decrypt in ASP.NET - Encryption doesn't match


Hello all,

I have a problem decrypting a string in ASP.NET wich was encrypted at PHP. As a testcase, i tried to encrypt 'test' in ASP.NET and in PHP, using 3DES in cbc mode. But the encrypted values don't match :(. I want the values to match, so i know for sure i use the same encryption method. Please help me on this, I just don't understand how there are different values...

Here's the code i use in php: 

$cc = "test";

$key = pack("c*", 0x13, 0x56, 0x23, 0x15, 0x81, 0x28, 0x56, 0x51, 0x13, 0x56, 0x23, 0x15, 0x81, 0x28, 0x56, 0x52, 0x13, 0x56, 0x23, 0x15, 0x81, 0x28, 0x56, 0x51);
$iv = pack("c*", 0x42, 0x32, 0x84, 0x25, 0x79, 0x43, 0x11, 0x37);

      $block = mcrypt_get_block_size('tripledes', 'cbc');
      $len = strlen($cc);
      $padding = $block - ($len % $block);
      $cc .= str_repeat(chr($padding),$padding);

$cipher = mcrypt_module_open(MCRYPT_3DES,'','cbc','');
mcrypt_generic_init($cipher, $key, $iv);
$encrypted = mcrypt_generic($cipher,$cc);
echo base64_en

encrypt and decrypt md5 hash text


i am encrypting textbox value in md5 using this coding and passing as querystring , and on other page i want to decrypt.....

so plz tell how can i do this..

System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
        byte[] bs = System.Text.Encoding.UTF8.GetBytes(TextBox1.Text);
        bs = x.ComputeHash(bs);
        System.Text.StringBuilder s = new System.Text.StringBuilder();
        foreach (byte b in bs)
        string password = s.ToString();

Decrypt the encrypted store procedure through the T-SQL programming in SQL Server 2005


HI ,


I have a encrypted store procedure in my production server .Right now I do not have the script now I want do some modification.

Please any one can help me to decrypt the store procedure it will be a great help for me.


For any suggestion thanks  in advance.

" Education is the beginning of transformation. Dedicate yourself to daily learning via Blogs/Forums/books and coaching "
Click here to read my blog

Failed to decrypt protected XML node "DTS:Password" with error 0x8009000B



I have developed several SSIS packages with the last Beta of VS2005 / SQL Server CTP. After the public release I tried to uninstall the CTP-Versions to install the msdn finals but this time I got lost and was not able to satisfy the requirements of the final setup of VS2005. So I decided to install the whole pc again and after some hours I had a clean machine (XP with latest SQL Server 2005 Standard and VS2005 Professional).


Now I have tried to open my SSIS-Project but getting the following error:


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 =

C# MD5CryptoServiceProvider Decrypt String



I have the following code to encrypt a string:

public static string MD5ComputeHexaHash(string text)
        // Gets the MD5 hash for text
        MD5 md5 = new MD5CryptoServiceProvider();
        byte[] data = Encoding.Default.GetBytes(text);
        byte[] hash = md5.ComputeHash(data);
        // Transforms as hexa
        string hexaHash = "";
        foreach (byte b in hash)
            hexaHash += String.Format("{0:x2}", b);
        // Returns MD5 hexa hash
        return hexaHash;

Now I need to reverse it to decrypt a string...

Any help?

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