Jannik Strelow

Digital Lifestyle

Page 2 of 13

Example SHA256 hash in C#

Here is short code snippet to create a SHA256 hash in C#. The only difficult is to convert from string to byte array and back again. So i have to method, one accept the byte array direct and returns a byte array, the second method handles the convert from string to byte array and back again. Don’t forget to add the required using:

using System.Security.Cryptography;

And here is the function:

        public static string GetSha256(string text)
        {
            if (text == null)
            {
                return string.Empty;
            }

            byte[] message = System.Text.Encoding.ASCII.GetBytes(text);
            byte[] hashValue = GetSha256(message);

            string hashString = string.Empty;
            foreach (byte x in hashValue)
            {
                hashString += string.Format("{0:x2}", x);
            }

            return hashString;

        }

        private static byte[] GetSha256(byte[] message)
        {
            SHA256Managed hashString = new SHA256Managed();
            return hashString.ComputeHash(message);
        }

How to create a SHA1 hash in C#

Here is short code snippet to create a SHA1 hash in C#. The only difficult is to convert from string to byte array and back again. So i have to method, one accept the byte array direct and returns a byte array, the second method handles the convert from string to byte array and back again. Don’t forget to add the required using:

Continue reading

How to create a md5 hash in C#

Here a quick example how to create from an string an md5 hash in c# and output it as string. The only difficult is to convert from string to byte array and back again. So i have to method, one accept the byte array direct and returns a byte array, the second method handles the convert from string to byte array and back again.

Continue reading

PHP PDO jQuery AJAX Example

I have found a very nice tutorial, how to use PHP, PDO, jQuery and the ajax technology to create, edit and delete records on a database table. I have copied the script and had make an online demo page from this project.

Its like my own German article how to use PHP and Ajax to edit a table on the MySQL database. Its interesting, how different the concepts are to create a editable MySQL table.

Feel free to compare the different scripts on this demo sites:
Preview the PHP PDO example from programmerblog.net.
Preview the mysql ajax edit table example from my blog.

Don’t forget to checkout the website from programmerblog.net, there are many good articles.

A propertygrid for javascript: jq PropertyGrid

I have found a useful jQuery Plugin to show very fast a javascript object as a form. Its jqPropertyGrid, you can easily show an object with one line of code: 

$(‘#property-grid’).jqPropertyGrid(record.data, options);

I have used the plugin to show fast and easy options for my form editor. Its pretty simple and makes it a lot of easier to make an object editable. Also you can with one command serialize the object back or you can use an event listener, so you get informed on every change the user has made on the property grid.

Continue reading
« Older posts Newer posts »

© 2021 Jannik Strelow

Theme by Anders NorenUp ↑