bytes_to_hex
/*
** 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;
}
** 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;
}
[Please Login]
Projects: 8
Contributor: xot
comments powered by Disqus

Related: