Skip to main content

Posts

Showing posts from September, 2014

BCrypt.net - Strong Password Hashing for .NET and Mono

Using raw hash functions to authenticate passwords is as naive as using unsalted hash functions. Don’t. Thomas Ptacek BCrypt.net is an implementation of OpenBSD's Blowfish-based password hashing code, described in " A Future-Adaptable Password Scheme " by  Niels Provos  and  David Mazières . It is a direct port of  jBCrypt  by  Damien Miller , and is thus released under the same BSD-style license. The code is fully managed and should work with any little-endian CLI implementation -- it has been tested with Microsoft .NET and Mono. Why BCrypt? Most popular password storage schemes are based on fast hashing algorithms such as MD5 and SHA-1. BCrypt is a computationally expensive adaptive hashing scheme which utilizes the Blowfish block cipher. It is ideally suited for password storage, as its slow initialization time severely limits the effectiveness of brute force password cracking attempts. How much overhead it adds is configurable (that's the...

Cast Object to Generic List

Lots of trial and error gave me this on SL 5 but it should also work on a regular C#. You also need to add LINQ to your using list for the last half to work. List <object> myAnythingList = ( value as IEnumerable <object> ). Cast <object> (). ToList () Ref :  http://stackoverflow.com/questions/2837063/cast-object-to-generic-list

DotNetOpenAuth.Asp Couldnt Load Assembly or one of its dependencies in MVC4 App Unit Tests

Error: Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Solution <configuration> <runtime> < assemblyBinding xmlns = "urn:schemas-microsoft-com:asm.v1" > <dependentAssembly> < assemblyIdentity name = "DotNetOpenAuth.AspNet" publicKeyToken = "2780ccd10d57b246" culture = "neutral" /> < bindingRedirect oldVersion = "0.0.0.0-4.3.0.0" newVersion = "4.3.0.0" /> </ dependentAssembly > <dependentAssembly> < assemblyIdentity name = "DotNetOpenAuth.Core" publicKeyToken = "2780ccd10d57b246" culture = "neutral" /> ...

Object to xml and write in text file using C# code

 public static void ObjectToXml(object obj, string path_to_xml)         {             //serialize and persist it to it's file             try             {                 System.Xml.Serialization.XmlSerializer writer =                 new System.Xml.Serialization.XmlSerializer(obj.GetType());                 System.IO.StreamWriter file =                 new System.IO.StreamWriter(path_to_xml);                 writer.Serialize(file, obj);                 file.Close();                 //XmlSerializer ser = new XmlSerializer(obj.GetType());             ...

SQL SERVER – Comma Separated Values (CSV) from Table Column

I use following script very often and I realized that I have never shared this script on this blog before. Creating Comma Separated Values (CSV) from Table Column is a very common task, and we all do this many times a day. Let us see the example that I use frequently and its output. USE  AdventureWorks GO -- Check Table Column SELECT  Name FROM  HumanResources.Shift GO -- Get CSV values SELECT  SUBSTRING ( ( SELECT  ','  +  s.Name FROM  HumanResources.Shift s ORDER BY  s.Name FOR  XML PATH ( '' )), 2 , 200000 )  AS  CSV GO I consider XML as the best solution in terms of code and performance. Further, as I totally prefer this option, I am not even including the linka to my other articles, where I have described other options. Do you use any other method to resolve this issue? Can you find any significant difference in performance between these options? Please leave your comm...