Click here to Skip to main content
15,898,374 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Ajax control toolkit Vs Jquery in asp.net Pin
anilpal26-Feb-09 20:30
anilpal26-Feb-09 20:30 
GeneralRe: Ajax control toolkit Vs Jquery in asp.net Pin
Ramkumar_S26-Feb-09 21:30
Ramkumar_S26-Feb-09 21:30 
GeneralRe: Ajax control toolkit Vs Jquery in asp.net Pin
anilpal26-Feb-09 22:00
anilpal26-Feb-09 22:00 
QuestionAbout the water mark on video files Pin
Abhishek Rana26-Feb-09 20:10
Abhishek Rana26-Feb-09 20:10 
AnswerRe: About the water mark on video files Pin
Christian Graus26-Feb-09 20:19
protectorChristian Graus26-Feb-09 20:19 
QuestionHelp me Pin
mani.thirumalai26-Feb-09 20:03
mani.thirumalai26-Feb-09 20:03 
AnswerRe: Help me Pin
Christian Graus26-Feb-09 20:19
protectorChristian Graus26-Feb-09 20:19 
GeneralDecrypt problem in asp.net Pin
mani.thirumalai26-Feb-09 20:44
mani.thirumalai26-Feb-09 20:44 
I am trying to decrypt the string in asp.net which is encryted in java.I am able to do it till some extent but its not completely decrypting.
Here i am putting the code of both (Decryption through ASP.NET and Encryption through Java)


private String Encrypt() /// Done in Java return encryted string
{
String hexString="";
String msg="Sample Input Text";
SecretKeySpec skeySpec ="GbxDwxcjvjtpi0+lQuyfHg=="; // Autogennerate Key

try
{
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(msg.getBytes());
hexString=asHex(encrypted);
}
catch(Exception e)
{
System.out.println("Error in Encrypt"+e);
}
return hexString;
}


private void DecryptFunction() // Done in Asp.net
{
try
{
string strEncrypt = "fc8caff8581f9a3920b788490c3569ffb345e54c7f72a73ddb76256ff81fbfd6";// Encrypt string
string AutoKey= "GbxDwxcjvjtpi0+lQuyfHg==";
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Key = Encoding.UTF8.GetBytes(AutoKey= );
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
ICryptoTransform crypt = tdes.CreateDecryptor();
byte[] cipher = FromHex(strEncrypt);
byte[] plain = crypt.TransformFinalBlock(cipher, 0, cipher.Length); // Here Error showing
Response.Write("Decryped string : " + System.Text.Encoding.UTF8.GetString(plain) + "<br/><br/><br/><br/>");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}

Here decryt function should be return decrypt string means Sample Input Text but its showing Bad Data error.
I give error screen shot also.

Server Error in '/WebSite1' 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 Details: System.Security.Cryptography.CryptographicException: Bad Data.


Source Error:


Line 76: ICryptoTransform crypt = tdes.CreateDecryptor();
Line 77: byte[] cipher = FromHex(strEncrypt);
Line 78: byte[] plain = crypt.TransformFinalBlock(cipher, 0, cipher.Length); // Here Error showing
Line 79: Response.Write("Decryped string : " + System.Text.Encoding.UTF8.GetString(plain) + "<br/><br/><br/><br/>");
Line 80:


Source File: c:\Documents and Settings\tmani.MILESDNS01\My Documents\Visual Studio 2005\WebSites\WebSite1\SSoFinal.aspx.cs Line: 78

Stack Trace:


[CryptographicException: Bad Data.
]
System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) +33
System.Security.Cryptography.Utils._DecryptData(SafeKeyHandle hKey, Byte[] data, Int32 ib, Int32 cb, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode PaddingMode, Boolean fDone) +0
System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) +200
SSoFinal.DecryptFunctionINGData() in c:\Documents and Settings\tmani.MILESDNS01\My Documents\Visual Studio 2005\WebSites\WebSite1\SSoFinal.aspx.cs:78
SSoFinal.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\tmani.MILESDNS01\My Documents\Visual Studio 2005\WebSites\WebSite1\SSoFinal.aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +31
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +68
System.Web.UI.Control.OnLoad(EventArgs e) +88
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3035




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42





I would appreciate some help

Regards
Mani
Questionhow to encrypt a query string value Pin
raghvendrapanda26-Feb-09 19:44
raghvendrapanda26-Feb-09 19:44 
AnswerRe: how to encrypt a query string value Pin
Christian Graus26-Feb-09 20:20
protectorChristian Graus26-Feb-09 20:20 
AnswerRe: how to encrypt a query string value Pin
anilpal26-Feb-09 20:26
anilpal26-Feb-09 20:26 
AnswerRe: how to encrypt a query string value Pin
keyur satyadev26-Feb-09 22:30
keyur satyadev26-Feb-09 22:30 
QuestionCrystal Report problem Pin
Mogaambo26-Feb-09 19:12
Mogaambo26-Feb-09 19:12 
AnswerRe: Crystal Report problem Pin
Abhishek Sur26-Feb-09 21:35
professionalAbhishek Sur26-Feb-09 21:35 
QuestionInsert Runtime Row in Gridview Control Pin
Vishal0926-Feb-09 18:35
Vishal0926-Feb-09 18:35 
AnswerRe: Insert Runtime Row in Gridview Control Pin
N a v a n e e t h26-Feb-09 18:51
N a v a n e e t h26-Feb-09 18:51 
Questiontest Pin
Member 464259126-Feb-09 17:31
Member 464259126-Feb-09 17:31 
AnswerRe: test Pin
Christian Graus26-Feb-09 17:55
protectorChristian Graus26-Feb-09 17:55 
Questionhow insert datatable to storedprocedure Pin
amit sahu2026-Feb-09 17:30
amit sahu2026-Feb-09 17:30 
AnswerRe: how insert datatable to storedprocedure Pin
Christian Graus26-Feb-09 17:57
protectorChristian Graus26-Feb-09 17:57 
GeneralRe: how insert datatable to storedprocedure Pin
amit sahu2026-Feb-09 18:41
amit sahu2026-Feb-09 18:41 
QuestionGridview in UpdatePanel (AJAX) Pin
Lash2026-Feb-09 13:19
Lash2026-Feb-09 13:19 
AnswerRe: Gridview in UpdatePanel (AJAX) Pin
sarang_k26-Feb-09 16:38
sarang_k26-Feb-09 16:38 
GeneralRe: Gridview in UpdatePanel (AJAX) Pin
Lash2027-Feb-09 3:39
Lash2027-Feb-09 3:39 
GeneralRe: Gridview in UpdatePanel (AJAX) Pin
Lash2027-Feb-09 5:28
Lash2027-Feb-09 5:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.