A
A
Alexey Lebedev2015-05-04 19:54:37
JavaScript
Alexey Lebedev, 2015-05-04 19:54:37

How to encode numbers into characters?

There is data that consists of 12 digits.
0-9
, (comma)
- (minus)
Before sending to the server, I want to encode in A-Za-z0-9+characters.
This will reduce traffic.
How can it be encrypted and decrypted?
Maybe there are libraries? preferably in JavaScript

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
mace-ftl, 2015-05-04
@swanrnd

I know a tricky way!
1) Take and present the first set of characters as a NUMBER in the 12-decimal system (0-9+","+"-")
2) Count how many CHARACTERS you have in the new system (A-Za-z0-9+characters)
3) You transfer to the system with the specified base - obviously the number will be SHORT
4) You transfer, everything is back on the other side
PS. with strings of 12 digits, this will give a better result than options with standard frequency stop algorithms

V
Vladimir Martyanov, 2015-05-04
@vilgeforce

base64 + optional GZIP. I would not bother with data compression at 12 bytes.

O
one pavel, 2015-05-04
@onepavel

Encode numbers into characters, create an array of 12 characters, numbers 0-9 will be array indexes, well, minus with a comma there too. And to encrypt in js from a hacker, in my opinion, is useless. Anyone who wants to, will parse any obfuscated code. and for users it may be enough xor to do.

E
Eugene, 2015-05-04
@cyber-jet

md5, SHA-2 hash, no?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question