i saw a code and that code had all string in a array.. And each array index was like: "\x31\x32\x33", etc..
How i can convert for example "hello" to that encode format?
if is possible, there a online encoder?
i saw a code and that code had all string in a array.. And each array index was like: "\x31\x32\x33", etc..
How i can convert for example "hello" to that encode format?
if is possible, there a online encoder?
As the @nikjohn said, you can decoded the string by console.log
.
And the following code I found from this question. And I made some changes, the output string will be in a \x48 \x65
form.
It will convert the string in a hex coding, and each character will be separated by a space:
String.prototype.hexEncode = function(){
var hex, i;
var result = "";
for (i=0; i<this.length; i++) {
hex = this.charCodeAt(i).toString(16);
result += ("\\x"+hex).slice(-4) + " ";
}
return result;
};
var str = "Hello";
console.log(str.hexEncode());
The result of the above code is \x48 \x65 \x6c \x6c \x6f
。
It is an hex coding encoding.
www.unphp.net
http://ddecode.com/hexdecoder/
http://string-functions.com/hex-string.aspx
are the few sites that can give you encoding and decoding using hex coding.
If you console log the string sequence, you get the decoded strings. So it's as simple as
console.log('\x31\x32\x33'); // 123
For encoding said string, you can extend the String prototype:
String.prototype.hexEncode = function(){
var hex, i;
var result = "";
for (i=0; i<this.length; i++) {
hex = this.charCodeAt(i).toString(16);
result += ("\\x"+hex).slice(-4);
}
return result
}
Now,
var a = 'hello';
a.hexEncode(); //\x68\x65\x6c\x6c\x6f