Click here to Skip to main content
15,916,042 members
Home / Discussions / C#
   

C#

 
QuestionDevice interface Pin
bannapradeep17-Jun-06 2:50
bannapradeep17-Jun-06 2:50 
AnswerRe: Device interface Pin
Dave Kreskowiak17-Jun-06 16:55
mveDave Kreskowiak17-Jun-06 16:55 
QuestionTeamWork Developement Pin
HRiazi17-Jun-06 2:41
HRiazi17-Jun-06 2:41 
AnswerRe: TeamWork Developement Pin
Tamimi - Code17-Jun-06 2:49
Tamimi - Code17-Jun-06 2:49 
AnswerRe: TeamWork Developement Pin
WillemM17-Jun-06 3:10
WillemM17-Jun-06 3:10 
AnswerRe: TeamWork Developement Pin
Jun Du17-Jun-06 5:36
Jun Du17-Jun-06 5:36 
AnswerRe: TeamWork Developement Pin
leppie17-Jun-06 6:42
leppie17-Jun-06 6:42 
QuestionDecrypting Username and Password Pin
wo1noreen17-Jun-06 1:30
wo1noreen17-Jun-06 1:30 
I was able to encrypt and decrypt the password with no problem at all. However, I needed to encrypt and decrypt the username also. When I copied my encrypt/decrypt password methods to encrypt/decrypt username...I can't decrypt the username anymore. The last 6 characters are correctly decrypted..but the first few characters are not..Sniff | :^) Please help! I'm stuck with this!

Here's the code:

private string GetDecryptedUsername()
{
string strReturn = "";
try
{
Decryptor dec = new Decryptor(algorithm);
dec.IV = Convert.FromBase64String(enc_setting.IV);
byte[] key = Convert.FromBase64String(enc_setting.EncryptKey);
byte[] plainText = dec.Decrypt(Convert.FromBase64String(enc_setting.Username),key );
strReturn = ASCIIEncoding.ASCII.GetString(plainText);
}
catch(Exception ex)
{
throw ex;
}
return strReturn;
}

private string GetDecryptedPassword()
{
string strReturn = "";
try
{
Decryptor dec = new Decryptor(algorithm);
dec.IV = Convert.FromBase64String(enc_setting.IV);
byte[] key = Convert.FromBase64String(enc_setting.EncryptKey);
byte[] plainText = dec.Decrypt(Convert.FromBase64String(enc_setting.Password), key);
strReturn = Encoding.ASCII.GetString(plainText);
}
catch(Exception ex)
{
throw ex;
}
return strReturn;

}

//----working----
private void GenerateEncryptedUsername(ref Setting settingU)
{
try
{
Encryptor enc = new Encryptor(algorithm);
byte[] plainText = Encoding.ASCII.GetBytes(settingU.Username);
byte[] key = Convert.FromBase64String(settingU.EncryptKey);
byte[] cipherText = enc.Encrypt(plainText, key);
settingU.IV = Convert.ToBase64String(enc.IV);
settingU.Username = Convert.ToBase64String(cipherText);

}

catch(Exception ex)
{
throw ex;
}
}
private void GenerateEncryptedPassword(ref Setting setting)
{
try
{
Encryptor enc = new Encryptor(algorithm);
byte[] plainText = Encoding.ASCII.GetBytes(setting.Password);
byte[] key = Convert.FromBase64String(setting.EncryptKey);
byte[] cipherText = enc.Encrypt(plainText, key);
setting.IV = Convert.ToBase64String(enc.IV);
setting.Password = Convert.ToBase64String(cipherText);

}

catch(Exception ex)
{
throw ex;
}
}



Thanks much,
wo1noreen
Questionexcel to dataView Pin
caliph17-Jun-06 0:08
caliph17-Jun-06 0:08 
AnswerRe: excel to dataView Pin
Robert Rohde17-Jun-06 11:11
Robert Rohde17-Jun-06 11:11 
QuestionHierachy Model Tab Control Pin
Haridas.R16-Jun-06 23:06
Haridas.R16-Jun-06 23:06 
QuestionData Bindings again Pin
rzvme16-Jun-06 22:36
rzvme16-Jun-06 22:36 
AnswerRe: Data Bindings again Pin
Bogdan Damian19-Jun-06 10:24
Bogdan Damian19-Jun-06 10:24 
QuestionDataGrid Class and its Methods Pin
Alamzeb khan16-Jun-06 22:30
Alamzeb khan16-Jun-06 22:30 
AnswerRe: DataGrid Class and its Methods Pin
Kevin McFarlane17-Jun-06 3:26
Kevin McFarlane17-Jun-06 3:26 
Questionopacity in usercontrol Pin
Nafiseh Salmani16-Jun-06 22:25
Nafiseh Salmani16-Jun-06 22:25 
Questionwindowsmediaplayer Pin
Amalarajan16-Jun-06 22:20
Amalarajan16-Jun-06 22:20 
QuestionData Grid Objects in C# Pin
Alamzeb khan16-Jun-06 21:45
Alamzeb khan16-Jun-06 21:45 
QuestionDatatable and Dataview Pin
Alamzeb khan16-Jun-06 21:29
Alamzeb khan16-Jun-06 21:29 
AnswerRe: Datatable and Dataview Pin
Nafiseh Salmani16-Jun-06 22:33
Nafiseh Salmani16-Jun-06 22:33 
QuestionHow to Search Pin
Alamzeb khan16-Jun-06 20:32
Alamzeb khan16-Jun-06 20:32 
AnswerRe: How to Search Pin
TheBeginner7716-Jun-06 21:01
TheBeginner7716-Jun-06 21:01 
QuestionInput box in c# Pin
Alamzeb khan16-Jun-06 20:01
Alamzeb khan16-Jun-06 20:01 
AnswerRe: Input box in c# Pin
Guffa16-Jun-06 22:12
Guffa16-Jun-06 22:12 
QuestionDelegates Pin
Alamzeb khan16-Jun-06 19:02
Alamzeb khan16-Jun-06 19:02 

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.