0

I need to shorten a long string with a variable length and "decode" it back later on. The string will be built up like this 0011010011 ........ etc.

My problem right now is that the string will be over a thousand characters long which is far far too long to easily copy and paste around.

Any ideas on how to do this?

read more

4
  • Do you mean that the string only has the characters 0 and 1? Commented Jun 27, 2016 at 14:50
  • 3
    encrypting is not the same as encoding. In this case I think you meant encoding. Commented Jun 27, 2016 at 14:50
  • Also, does the string have a length that is a multiple of 8? If so, you could parse each 8 bytes as a binary integer, and store it in a Uint8Array. That would yield a compression of 8 to 1. Commented Jun 27, 2016 at 14:52
  • Another way to go is to look into using some form of Run-length encoding if you expect the string to have long runs of 1s or 0s. Commented Jun 27, 2016 at 14:54

1 Answer 1

-1

Javascript doesn't support binary data by default. I would either use an exisiting package such as binstring or write your own encoding function

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.