Posts

Showing posts with the label mvc

Encrypt and Decrypt in c#

Step 1 :  using the following assembly using System.Security.Cryptography; Step 2 : add Encrypt & Decrypt mehtod to your class public string Encrypt(string clearText, string Password)         {             byte[] clearData = Encoding.Unicode.GetBytes(clearText);             PasswordDeriveBytes bytes = new PasswordDeriveBytes(Password, new byte[] { 50, 21, 32, 119, 19, 4, 56, 76, 23, 65, 58, 23, 43 });             return Convert.ToBase64String(this.Encrypt(clearData, bytes.GetBytes(0x20), bytes.GetBytes(0x10)));         } public string Decrypt(string cipherText, string Password)         {             byte[] cipherData = Convert.FromBase64String(cipherText);             PasswordDeriveBytes bytes = new PasswordDeriveBytes(Password, new byte[] { 50, 21, 32...

How to Sorting Genric List By Their Properties in c#

** To sort generic lists ,The following steps are required for sorting the list: Step1 :  Create class for sorting and implement interface IComparable<Type> wheres Type will reflect class for comparison Ex:  public class Racer : IComparable<Racer> Step 2 :  Add properties in the above class : Ex:         public string FirstName { get; set; }         public string LastName { get; set; }         public string Country { get; set; }         public int Wins { get; set; } Step 3 :  You have to override method of IComparable but it won't be executed for sorting : Ex:  public int CompareTo(Racer other) Step 4 : Create a class for doing comparison which will implement IComparer for doing comparison Ex: public class RacerComparer : IComparer<Racer> Step 5 :  Add enum to save what will be items t...