pack H* C# conversion 

Posted by Ron Rechtman Wednesday, June 02, 2010 9:39:10 AM

So I had to do manipulate data to a PHP app that needed to be pack("H*",...) in the PHP world. After a lot of digging I found

    public static byte[] PackH(string hex)
        {
            if ((hex.Length % 2) == 1) hex += '0';
            byte[] bytes = new byte[hex.Length / 2];
            for (int i = 0; i < hex.Length; i += 2)
            {
                bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
            }
            return bytes;
        }
Share This Using Popular Bookmarking Services
You must sign in to this site to post comments.
Site Map | Printable View | © 2008 - 2010 NuRoN Consulting, INC | Powered by mojoPortal | XHTML 1.0 | CSS | Original design by Andreas Viklund | Designed by NuRoN Consulting, INC.
Share This Using Popular Bookmarking Services