Thursday, May 8, 2014

Some Hashing functions


     public static string SHA1Hash(string to_be_hash)
        {
        SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
        byte[] hash = sha1.ComputeHash(GetBytes(to_be_hash));
        string delimitedHexHash = BitConverter.ToString(hash);
        string hexHash = delimitedHexHash.Replace("-", "");
        return hexHash;
        }

        public static string HMACRIPEMD160Hash(string to_be_hash)
         {
             Guid g = new Guid("AD56BC66-3C2F-4B69-B9C9-1E0305D95E99");
             byte[] temp = null;
             using (HMACRIPEMD160 hmac = new HMACRIPEMD160(g.ToByteArray()))
             {
                 temp = hmac.ComputeHash(GetBytes(to_be_hash));
             }
             //return Convert.ToBase64String(temp);
             return ByteArrayToString(temp);
           }


Readonly on reference types

    public class testReadonly
    {
        public  readonly List<string> l = new List<string>();  
    }
    

     testReadonly tr = new testReadonly();

            tr.l.Add("fdgdgf"); 


this is ok because of this

Wednesday, May 7, 2014

KnownTypes

why they are needed

The type or namespace name 'Blah' does not exist in the namespace 'heh.heh' (are you missing an assembly reference?)

I was getting this in a team city build because the dll was directly referenced instead of the project being referenced.

This has great consequences with release builds
As I understand it,only with a project reference is the bin created

OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name

this happened with an unhandled error that didn't have wcf fault shielding

Friday, May 2, 2014

REST Clients

I had a situation where I needed to pass security in  a HTTP header - Postman worked while SOAPUI didn't

Compound Tertiary Operators

if you don't surround with parenthesis - you can have some funky errors