bytes_to_hex

Downloadbytes_to_hex(str)   Returns a string of hexadecimal digits converted from the given string of bytes.
/*
**  Usage:
**      bytes_to_hex(str)
**
**  Arguments:
**      str     a string of bytes, eight bits per character
**
**  Returns:
**      a string of hexadecimal digits, four bits per character
**
**  GMLscripts.com
*/

{
    var str,hex,h,l,p,byte;
    str = argument0;
    hex = "";
    h = "0123456789ABCDEF";
    l = string_length(str);
    for (p=1;p<=l;p+=1) {
        byte = ord(string_copy(str,p,1));
        hex += string_copy(h,byte div 16 + 1,1);
        hex += string_copy(h,byte mod 16 + 1,1);
    }
    return hex;
}

Click if you've used this script[Please Login]
Projects: 8


comments powered by Disqus