reverse base58 encoding - decoding? - javascript

On this site forknote creator in the second input box you enter a decimal value and it display the decoded prefix on the right.
Is it possible to reverse the js function so that you can enter text ie "BOB" and it displays the decimal value?
I think the "BOB" need to be converted to bytes? then to base 58 hex and convert the hex to dec?
Thanks

Every value encoded by baseXX function can be decoded. But this answer doesn't solve your problem. I looked at the code behind this input and it's way more complicated and has many cryptographic functions. I don't know if it's reversible.

Related

How to truncate an hex address?

So im writing an exploit and im getting an address such as 0x00708001e9ab0b10 which is obviously a 64 bit hex address. The address I need is 0x1e9ab0b10 to my calculations this is the upper 28 bits but some told me this is 48 bits and up so i dont know but i basically need to remove 0x0070800 the first 7 numbers of the hex string/number and give me something like 0x00000001e9ab0b10 which i would prefer!!! or something like 0x1e9ab0b10 mind you as well i need this done in JavaScript which is what my exploit is for
Not sure I properly understand what you want, but if that hex is a string, you can call String.prototype.slice(x) on it which returns a copy of the string with the first x characters removed.
truncate = (hexString) => '0x0000000' + hexString.slice(9);
truncate('0x00708001e9ab0b10');
If the actual number isn't of any consequence then convert it into a string and slice it.
console.log('0x'+0x00708001e9ab0b10.toString(16).slice(5))

Convert Decimal to Hex or Unicode using Javascript

the problem i'm facing is when i inputting emoji from an android device to display on a browser, the emoji is converted its form of Decimal code like 💙 💙 💙. is there any way to detect the decimal code then convert it to Hex or Unicode with javascript? because with Hashtag in front of the number, it might lead to confusion as hashtag input.
I've used the toString() method but it doesn't seem to solve the problem
decimalNumber.toString( radix )
maybe use \u---- where ---- is hexacode ( in utf8 string) ?

UTF-8 vs UTF-16 and UTF-32 conversion confusion

I'm kinda confused about conversion of unicode characters into hexadecimal values.
I'm using this website to get hexadecimal value for characters. (https://www.branah.com/unicode-converter)
If I put "A" and convert then I get something like:
0041 --> UTF-16
00000041 --> UTF-32
41 --> UTF-8
00065 --> Decimal Value
This above output makes sense because we can convert all these hexadecimal values into 65.
Now, If i put "Я" (without quotes) and convert it then I get values like.
042f --> UTF-16
0000042f --> UTF-32
d0af --> UTF-8
01071 --> Decimal Value
This output doesn't make sense to me because not all these hexadecimal values convert back to 1071.
If you you take d0af and try to convert it back to decimal value then you will get 53423.
This is something that is really confusing for me and I've searching online to find answers about this conversion but so far I've not been able to find any good answer.
So, I'm wondering if anyone here can help. (that would mean alot) // Thanks in advance.
you can also see below link for example of this conversion in binary. (and can you explain why utf-8 binary value is different in last example??)
http://kunststube.net/encoding/
UTF-8 uses variable length encoding (can use 1, 2, 3 or 4 bytes to store a single character).
In this case:
d0af = 11010000 10101111
110 at the start tells us to expect 2 bytes when decoding it (looking at the byte 1 column of the schematic). When decoding we use the binary digits that follow the first 0 in the byte. So,
110x xxxx the x's are our first lot of values for our actual unicode value. Every additional byte follows the pattern of 10xx xxxx. So taking the values from byte 1 & 2 we get:
110[10000] 10[101111] =
V V
10000 101111 = 42f = 1071
The reason this is done is that for common characters less bytes are needed for transmission and storage. But on the odd occasion that a uncommon character is needed it can still be used at part of UTF-8.
If you have any questions, please comment.

Unexpected behavior adding stringified integer to decimal in js

I had a strange bug that I just found the source of in my code.
"1" + .88 // 10.88
What's going on here?
When adding a number and a string (whatever their order), the number is converted to a string and then the two are concatenated.
.88.toString()
is
"0.88"
So you get the string
"10.88"
which appears as
10.88
in most contexts (for example in an HTML input).
If you want a specification based analysis, it starts here with
Then the number to string conversion with the leading 0.is described here:
(s=88, k=2, n=0)

storing and passing long numeric strings in node & jquery

(newbie here)
i have large floating-point arrays created by node.js that i need to pass to s client-side jquery-ajax function. the goal is download it the fastest way possible.
we can safely round off the floating-point to the hundredth position, maybe even the tenth position - but i still need to experiment to see which one works best.
so far i have multiplied each array value by 100 and rounded off to just have three digits:
wholeNbrValue = Math.round(floatingPointValue * Math.pow(10, 3));
so for example 0.123456 would become 123. then each set of digits is appended to a string:
returnString += sprintfJs('%03d', wholeNbrValue) ;
i end up with a rather long ascii string of digits. then i might use something like fs.createWriteStream to store the string on the server as an ordinary file, and later use jquery-ajax to fetch it on the client side.
my question: what might be the optimum way to store a numeric only string? i am tempted to loop back through the string again and use something like charCodeAt() and just grab up every two positions as an ascii value, or even grab every 64 digits and convert it to a four-byte hex value.
or perhaps is there some way using node to actually store a binary floating-point array and later retrieve it with jquery-ajax?
thank you very much.

Categories