Skip to main content

Posts

Showing posts with the label Utilities

Encrypt and Decrypt Data

There are many instance where we need to encrypt and decrypt data. Here is a class which does the job.     public class CryptographyHelper     {         static byte [] entropy = Encoding .Unicode.GetBytes( "Salt Is Not A Password" );         public static string EncryptString(System.Security. SecureString input)         {             byte [] encryptedData = System.Security.Cryptography. ProtectedData .Protect(                 System.Text. Encoding .Unicode.GetBytes(ToInsecureString(input)),                 entropy,                 System.Security.Cr...

Write Object in CSV/Excel File

There are many instance where we need to write an object in to CSV or Excel file, here is a CSVHelper class which will server this purpose. Below is the a user defined attribute, we need to apply this attribute to the properties which we want to write in Excel file.     /// <summary>     /// The name of the column for the CSV     /// generated by a list of objects with     /// properties marked with this attribute,     /// if Export is true.  Uses Order to order     /// the properties on export     /// </summary>     public class CsvColumnNameAttribute : Attribute     {         public bool Export { get ; set ; }         public int Order { get ; set ; }         public string Name { get ; ...