encryption method with numeric output - javascript

I'm looking for a two way encryption method that will output only numbers approx 9 char length.
somthing like skip32, but I cannot use skip32.
I need it to be available to php and javascript. Thank you.

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))

reverse base58 encoding - decoding?

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.

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.

Javascript parseFloat 10 instead of e

Im using parseFloat on very high numbers or very low numbers.
The return value is like 123*10e15 , I need to be like 123*10^15 . 15 needs to be in upper writing as a pow.
Thanks.
parseFloat turns a string into a number. A number has no "format"; it gets turned back into a string (by Float's method toString) when you display it. If you want to display it with a caret, you will need to format (or reformat) it yourself into a string: easiest like this:
123e45.toString().replace('e', '*10^') // result: "1.23*10^+47"
(if the + bugs you, you can try this, using a regexp:)
123e-45.toString().replace(/e\+?/, '*10^') // result: "1.23*10^47"

Javascript - extract specific numbers from string

I'm trying to extract specific numbers from a string but I'm not sure how to execute it.
The string is of the form:
center=43.571464,7.129565&zoom=12&size=480x225&markers=color:red%7Clabel:1%7C43.580293713725936,7.115145444335894&markers=color:red%7Clabel:2%7C43.56512073056565,7.121668576660113&sensor=false
The array I want is the marker coordinates near the end, specifically:
[43.580293713725936,7.115145444335894,43.56512073056565,7.121668576660113]
I thought I could pick these number out using their precision (15) but I don't know if that's best. I'm a hack when it comes to using regular expressions. Right now the best I've got is:
str.match(/[-+]?[0-9]*\.?[0-9]+/g)
But that just gives me all of the numbers.
Help much appreciated!
If your string is in str use this regex.
var coordinates = decodeURIComponent(str).match(/([\d.]{10,})/g);
http://jsfiddle.net/CHfcT/
You could try using the following regex
/\d+\.\d{7,}/g
This assumes that:
The marker coordinates always have 7 or more numbers after the dot
No other part of the string contains a similar pattern with more than 7 numbers after a dot
Example (JSFiddle):
str.match(/\d+\.\d{7,}/g);
The reason I picked 7 was because the other numbers in the sample had 6, so that excludes them. If you know that the coordinates always have a fixed number of decimal places, then you could just use that specific number without the , like this:
/\s+\.\d{10}/g

Categories