Click here to Skip to main content
15,913,685 members
Home / Discussions / C#
   

C#

 
GeneralRe: Compare data entered through multiple input fields with stored values in dataset. Pin
Rajesh_19801-Sep-15 5:11
Rajesh_19801-Sep-15 5:11 
QuestionTargetInvocationException Pin
Gilbert Consellado29-Aug-15 22:48
professionalGilbert Consellado29-Aug-15 22:48 
AnswerRe: TargetInvocationException Pin
Pete O'Hanlon30-Aug-15 0:01
mvePete O'Hanlon30-Aug-15 0:01 
GeneralRe: TargetInvocationException Pin
Gilbert Consellado30-Aug-15 0:52
professionalGilbert Consellado30-Aug-15 0:52 
GeneralRe: TargetInvocationException Pin
Herman<T>.Instance1-Sep-15 4:31
Herman<T>.Instance1-Sep-15 4:31 
AnswerRe: TargetInvocationException Pin
Eddy Vluggen30-Aug-15 0:44
professionalEddy Vluggen30-Aug-15 0:44 
GeneralRe: TargetInvocationException Pin
Gilbert Consellado30-Aug-15 0:59
professionalGilbert Consellado30-Aug-15 0:59 
QuestionCreating an Auto Purchase Order no with Prefix in asp.net Pin
Member 1158609829-Aug-15 2:05
Member 1158609829-Aug-15 2:05 
AnswerRe: Creating an Auto Purchase Order no with Prefix in asp.net Pin
OriginalGriff29-Aug-15 2:21
mveOriginalGriff29-Aug-15 2:21 
AnswerRe: Creating an Auto Purchase Order no with Prefix in asp.net Pin
Dave Kreskowiak29-Aug-15 6:53
mveDave Kreskowiak29-Aug-15 6:53 
GeneralRe: Creating an Auto Purchase Order no with Prefix in asp.net Pin
Pete O'Hanlon29-Aug-15 11:13
mvePete O'Hanlon29-Aug-15 11:13 
AnswerRe: Creating an Auto Purchase Order no with Prefix in asp.net PinPopular
Pete O'Hanlon29-Aug-15 10:05
mvePete O'Hanlon29-Aug-15 10:05 
GeneralRe: Creating an Auto Purchase Order no with Prefix in asp.net Pin
OriginalGriff29-Aug-15 20:30
mveOriginalGriff29-Aug-15 20:30 
QuestionHow can write Algorithm for the following question? Pin
BUNER28-Aug-15 7:55
BUNER28-Aug-15 7:55 
AnswerRe: How can write Algorithm for the following question? Pin
OriginalGriff28-Aug-15 8:07
mveOriginalGriff28-Aug-15 8:07 
GeneralRe: How can write Algorithm for the following question? Pin
BUNER28-Aug-15 8:29
BUNER28-Aug-15 8:29 
GeneralRe: How can write Algorithm for the following question? Pin
OriginalGriff28-Aug-15 8:36
mveOriginalGriff28-Aug-15 8:36 
GeneralRe: How can write Algorithm for the following question? Pin
BUNER28-Aug-15 10:43
BUNER28-Aug-15 10:43 
GeneralRe: How can write Algorithm for the following question? Pin
OriginalGriff28-Aug-15 22:19
mveOriginalGriff28-Aug-15 22:19 
AnswerRe: How can write Algorithm for the following question? Pin
Eddy Vluggen28-Aug-15 9:14
professionalEddy Vluggen28-Aug-15 9:14 
GeneralRe: How can write Algorithm for the following question? Pin
BUNER28-Aug-15 10:41
BUNER28-Aug-15 10:41 
this is the algorithem

class MainClassForAlgo
{

public static string EncryptString(string Message, string Passphrase)
{
byte[] Results;
System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();



MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));
// Step 2. Create a new TripleDESCryptoServiceProvider object
TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();

// Step 3. Setup the encoder
TDESAlgorithm.Key = TDESKey;
TDESAlgorithm.Mode = CipherMode.ECB;
TDESAlgorithm.Padding = PaddingMode.PKCS7;

// Step 4. Convert the input string to a byte[]
byte[] DataToEncrypt = UTF8.GetBytes(Message);

// Step 5. Attempt to encrypt the string
try {
ICryptoTransform Encryptor = TDESAlgorithm.CreateEncryptor();
Results = Encryptor.TransformFinalBlock(DataToEncrypt, 0, DataToEncrypt.Length);
}
finally
{
// Clear the TripleDes and Hashprovider services of any sensitive information
TDESAlgorithm.Clear();
HashProvider.Clear();
}

// Step 6. Return the encrypted string as a base64 encoded string
return Convert.ToBase64String(Results);
}

public static string DecryptString(string Message, string Passphrase)
{
byte[] Results;
System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();


MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));

// Step 2. Create a new TripleDESCryptoServiceProvider object
TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();

// Step 3. Setup the decoder
TDESAlgorithm.Key = TDESKey;
TDESAlgorithm.Mode = CipherMode.ECB;
TDESAlgorithm.Padding = PaddingMode.PKCS7;
// Step 4. Convert the input string to a byte[]
byte[] DataToDecrypt = Convert.FromBase64String(Message);

// Step 5. Attempt to decrypt the string
try
{
ICryptoTransform Decryptor = TDESAlgorithm.CreateDecryptor();
Results = Decryptor.TransformFinalBlock(DataToDecrypt, 0, DataToDecrypt.Length);
}
finally
{
// Clear the TripleDes and Hashprovider services of any sensitive information
TDESAlgorithm.Clear();
HashProvider.Clear();
}

// Step 6. Return the decrypted string in UTF8 format
return UTF8.GetString( Results );
}

public static void Main(string[] args)
{
// The message to encrypt.
string Msg = "poultry outwits ants";
string Password = "4624d200580677270a54ccff86b9610e";

string EncryptedString = EncryptString("poultry outwits ants", Password);
string DecryptedString = DecryptString(EncryptedString, Password);

Console.WriteLine("Message: {0}",Msg);
Console.WriteLine("Password: {0}",Password);
Console.WriteLine("Encrypted string: {0}",EncryptedString);
Console.WriteLine("Decrypted string: {0}",DecryptedString);
Console.ReadKey();
}
}
QuestionXAML Templates for Win 10 Pin
Don Rolando28-Aug-15 7:39
Don Rolando28-Aug-15 7:39 
AnswerRe: XAML Templates for Win 10 Pin
Evil Iceblock1-Sep-15 19:09
Evil Iceblock1-Sep-15 19:09 
Questionaccess to localdb from different pcs in a lan network Pin
Member 1189642727-Aug-15 7:00
Member 1189642727-Aug-15 7:00 
AnswerRe: access to localdb from different pcs in a lan network Pin
OriginalGriff27-Aug-15 8:10
mveOriginalGriff27-Aug-15 8:10 

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.