1var rgbToHex = function (rgb) {
2 var hex = Number(rgb).toString(16);
3 if (hex.length < 2) {
4 hex = "0" + hex;
5 }
6 return hex;
7};
1function ascii_to_hex(str)
2 {
3 var arr1 = [];
4 for (var n = 0, l = str.length; n < l; n ++)
5 {
6 var hex = Number(str.charCodeAt(n)).toString(16);
7 arr1.push(hex);
8 }
9 return arr1.join('');
10 }