|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
NTE_BAD_DATA error with RSACryptoServiceProviderI am writing a string encrypt/decrypt for Pocket PC device using RSACryptoServiceProvider class(OpenNETCF.Security.Cryptography) and able the encrypt the string but getting the error while decrypting Code snippets as follows string pwdStr = "" test ; //Encrypt public string EncryptStr(string pwdStr) { RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(OpenNETCF.Security.Cryptography.NativeMethods.KeySpec.KEYEXCHANGE, true); byte[] cryptdata = rsa.EncryptValue(Encoding.UTF8.GetBytes(pwdStr)); string EncCredentials = Convert.ToBase64String(cryptdata, 0, cryptdata.Length); return EncCredentials; } //Decrypt public string DecryptStr(string pwdStr1) { RSACryptoServiceProvider rsa1 = new RSACryptoServiceProvider(OpenNETCF.Security.Cryptography.NativeMethods.KeySpec.KEYEXCHANGE, true); byte[] decryptdata = rsa1.DecryptValue(Encoding.UTF8.GetBytes(pwdStr1)); //Getting "bNb.Sec: NTE_BAD_DATA" error here string DecCredentials = Convert.ToBase64String(decryptdata, 0, decryptdata.Length); return DecCredentials; } Thanks for any help Rgds, Varsha Most of the time this errors comes when Key or vector are not the same for
encryption and decryption Show quoteHide quote "venkateswa***@gmail.com" wrote: > Hi, > > I am writing a string encrypt/decrypt for Pocket PC device using > RSACryptoServiceProvider class(OpenNETCF.Security.Cryptography) and > able the encrypt the string but getting the error while decrypting > > Code snippets as follows > > string pwdStr = "" test ; > //Encrypt > public string EncryptStr(string pwdStr) > { > > RSACryptoServiceProvider rsa = new > RSACryptoServiceProvider(OpenNETCF.Security.Cryptography.NativeMethods.KeySpec.KEYEXCHANGE, > true); > byte[] cryptdata = rsa.EncryptValue(Encoding.UTF8.GetBytes(pwdStr)); > string EncCredentials = Convert.ToBase64String(cryptdata, 0, > cryptdata.Length); > > return EncCredentials; > } > > //Decrypt > public string DecryptStr(string pwdStr1) > { > RSACryptoServiceProvider rsa1 = new > RSACryptoServiceProvider(OpenNETCF.Security.Cryptography.NativeMethods.KeySpec.KEYEXCHANGE, > true); > byte[] decryptdata = > rsa1.DecryptValue(Encoding.UTF8.GetBytes(pwdStr1)); > > //Getting "bNb.Sec: NTE_BAD_DATA" error here > string DecCredentials = Convert.ToBase64String(decryptdata, 0, > decryptdata.Length); > > return DecCredentials; > } > > Thanks for any help > > Rgds, > Varsha > >
Prevent others from using my class libraries
Decryptionfailed to bring original text back.... Simple Keyed hash question What's wrong with my encryption function? Newbie Question - Thanks in Advance... Keyed hash vs Digital signature ???? Security Exception and Windows Vista Getting the Access Permissions for a specific SID on a File / folder random passwords Security problems |
|||||||||||||||||||||||