Click here to Skip to main content
15,886,799 members
Home / Discussions / C#
   

C#

 
GeneralRe: Setup & Deployment project - "All User" installation Pin
Heath Stewart22-Apr-04 3:52
protectorHeath Stewart22-Apr-04 3:52 
GeneralRe: Setup & Deployment project - "All User" installation Pin
Ruchi Gupta22-Apr-04 4:52
Ruchi Gupta22-Apr-04 4:52 
QuestionHow can i make an event on the scrollbar of the TreeView Pin
amr_tahlawi21-Apr-04 11:49
amr_tahlawi21-Apr-04 11:49 
AnswerRe: How can i make an event on the scrollbar of the TreeView Pin
Heath Stewart21-Apr-04 12:26
protectorHeath Stewart21-Apr-04 12:26 
GeneralForms.ComboBox Pin
yaakov7721-Apr-04 11:02
yaakov7721-Apr-04 11:02 
GeneralRe: Forms.ComboBox Pin
Michael Wolski21-Apr-04 18:23
Michael Wolski21-Apr-04 18:23 
GeneralRe: Forms.ComboBox Pin
yaakov7721-Apr-04 22:55
yaakov7721-Apr-04 22:55 
Generalc# RSACryptoServiceProvider encryption - stored passwords Pin
judyvjudy21-Apr-04 9:57
judyvjudy21-Apr-04 9:57 
Smile | :) Hi-
I have a c# program which encrypts a password and stores it in an access database (into a text field with 150 char). When I try to decrypt it, it tells me "bad data".

Here is how I encrypt it:
//Create a UnicodeEncoder to convert between byte array and string.
UnicodeEncoding ByteConverter = new UnicodeEncoding();

//Create byte arrays to hold original, encrypted, and decrypted data.
byte[] dataToEncrypt = ByteConverter.GetBytes(this.editHeartsPsWd.Text.ToString());
byte[] encryptedData;

//Create a new instance of RSACryptoServiceProvider to generate
//public and private key data.
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();

//Pass the data to ENCRYPT, the public key information
//(using RSACryptoServiceProvider.ExportParameters(false),
//and a boolean flag specifying no OAEP padding.
encryptedData = HallenSchool.HallenFunctions.RSAEncrypt(dataToEncrypt,RSA.ExportParameters(false), false);


string sSQL="UPDATE Staff SET Staff.HeartsPsWd = '" + ByteConverter.GetString(encryptedData) + "' WHERE Staff.[Staff Code]= " + this.editStaff_Code.Text.ToString();


Here is how I decrypt it:
//Create a UnicodeEncoder to convert between byte array and string.
UnicodeEncoding ByteConverter = new UnicodeEncoding();

//Create a new instance of RSACryptoServiceProvider to generate
//public and private key data.
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();

byte[] decryptedData;
byte[] encryptedData;

string strHeartsPsWd = this.editHeartsPsWd.Text.ToString();
strHeartsPsWd = strHeartsPsWd.Trim();
encryptedData=ByteConverter.GetBytes(strHeartsPsWd);
if (!(encryptedData.Length==0))
{
decryptedData = HallenSchool.HallenFunctions.RSADecrypt(encryptedData,RSA.ExportParameters(true), false);

this.editHeartsPsWd.Text= ByteConverter.GetString(decryptedData);
}// not empty password

Thanks for your help!



JK

GeneralRe: c# RSACryptoServiceProvider encryption - stored passwords Pin
Heath Stewart21-Apr-04 10:14
protectorHeath Stewart21-Apr-04 10:14 
GeneralRe: c# RSACryptoServiceProvider encryption - stored passwords Pin
judyvjudy21-Apr-04 11:56
judyvjudy21-Apr-04 11:56 
GeneralRe: c# RSACryptoServiceProvider encryption - stored passwords Pin
Heath Stewart21-Apr-04 12:22
protectorHeath Stewart21-Apr-04 12:22 
QuestionHow to access the Inner class in C#? Pin
Anonymous21-Apr-04 9:54
Anonymous21-Apr-04 9:54 
AnswerRe: How to access the Inner class in C#? Pin
Heath Stewart21-Apr-04 10:08
protectorHeath Stewart21-Apr-04 10:08 
AnswerRe: How to access the Inner class in C#? Pin
scadaguy21-Apr-04 10:11
scadaguy21-Apr-04 10:11 
AnswerRe: How to access the Inner class in C#? Pin
Stefan Troschuetz21-Apr-04 20:43
Stefan Troschuetz21-Apr-04 20:43 
GeneralUrgent.. need a sw that cuts video into images and compatible with .NET Pin
MDM_RVS21-Apr-04 9:26
MDM_RVS21-Apr-04 9:26 
GeneralPivotTable and DataSet Pin
hxxbin21-Apr-04 8:16
hxxbin21-Apr-04 8:16 
GeneralRe: PivotTable and DataSet Pin
Heath Stewart21-Apr-04 8:53
protectorHeath Stewart21-Apr-04 8:53 
GeneralRe: PivotTable and DataSet Pin
hxxbin22-Apr-04 4:47
hxxbin22-Apr-04 4:47 
GeneralRe: PivotTable and DataSet Pin
Heath Stewart22-Apr-04 4:56
protectorHeath Stewart22-Apr-04 4:56 
GeneralI need an example of application.. Pin
benqazou21-Apr-04 8:12
benqazou21-Apr-04 8:12 
GeneralRe: I need an example of application.. Pin
Heath Stewart21-Apr-04 8:42
protectorHeath Stewart21-Apr-04 8:42 
GeneralRe: I need an example of application.. Pin
Andrew McCarter21-Apr-04 8:50
Andrew McCarter21-Apr-04 8:50 
Questionhow do i change the papersize to legal Pin
cmarmr21-Apr-04 8:07
cmarmr21-Apr-04 8:07 
AnswerRe: how do i change the papersize to legal Pin
Heath Stewart21-Apr-04 8:41
protectorHeath Stewart21-Apr-04 8:41 

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.