Category: Programming

  • HTTP header CSV type

    HTTP header CSV type

    The right HTTP header content-type for CSV files is the following:

    text/csv
    

    The complete HTTP header:

    Content-Type: text/csv
    

    In PHP you should use for an CSV file download the following lines at the start of the file:

    <?php
    header("Content-Type: text/csv");
    // after this line you output the content of the csv file
    

    In C#/ASP .Net you use the following code in the code behind file:

    this.Response.ContentType = "text/csv";
    
  • C# Sha512 hash example

    C# Sha512 hash example

    This is a brief demonstration of how to generate a Sha512 hash in C#. Make sure to include the using at the top of your code because we are using the System.Security.Cryptography methods.

    (more…)
  • How to create a SHA1 hash in C#

    How to create a SHA1 hash in C#

    This is a brief piece of C# code that generates a SHA1 hash. Converting a string to a byte array and back again is the only challenging part.

    I therefore need two methods:

    • the first takes the byte array directly and returns a byte array,
    • the second converts the string to byte array and back again.

    Remember to include the necessary using:

    (more…)
  • How to create a md5 hash in C#

    How to create a md5 hash in C#

    This is a quick example of how to generate an MD5 hash from a string in C# and output it as a string. Converting a string to a byte array and back again is the only challenging part. I therefore need two methods: the first takes the byte array directly and returns a byte array, while the second converts the string to byte array and back again.

    Weiterlesen