简体   繁体   中英

How to get an encrypted token minimized?

I have generated an encrypted token from Blowfish. Eg:- 7$127O$137kI$137mK$07WK$01$26m$05zYbJmCmUw$16nF$11G$27A2Gv$19Jm8$26eJ9kUv$07$118q$05$02$24KP8j$208$16$06$100P$11

Just out of curiosity , can I get this token more minimized/simplify/striped somehow. Can anything to be done in order to get this more so simplified , may be any encoding. Please help me out with this.

Thanks

Try Huffman encoding with your string. For the string 7$127O$137kI$137mK$07WK$01$26m$05zYbJmCmUw$16nF$11G$27A2Gv$19Jm8$26eJ9kUv$07$118q$05$02$24KP8j$208$16$06$100P$11

the compression ratio is 0.536830357143 .

Analysis

Memory requirements: ASCII: 896 bit      , Huffman: 593 bit
            Entropy: ASCII: 1.01833029706, Huffman: 1.05223637886
Average code length: ASCII: 8 bit        , Huffman: 4.29464285714 bit
Compression rate: 0.536830357143 

+---------+-------+-------+-----------+---------+---------+
| Seq.no. | Chars | ASCII | Frequency | Huffman |  ASCII  |
+---------+-------+-------+-----------+---------+---------+
|       0 | '$'   |    36 |        22 |       0 |  100100 |
|       1 | '0'   |    48 |        10 |    1111 |  110000 |
|       2 | '1'   |    49 |        14 |      11 |  110001 |
|       3 | '2'   |    50 |         8 |    1011 |  110010 |
|       4 | '3'   |    51 |         2 |  110100 |  110011 |
|       5 | '4'   |    52 |         1 |  101111 |  110100 |
|       6 | '5'   |    53 |         2 |  111001 |  110101 |
|       7 | '6'   |    54 |         5 |     100 |  110110 |
|       8 | '7'   |    55 |         7 |    1000 |  110111 |
|       9 | '8'   |    56 |         4 |   11011 |  111000 |
|      10 | '9'   |    57 |         2 |  110011 |  111001 |
|      11 | 'A'   |    65 |         1 | 1100001 | 1000001 |
|      12 | 'C'   |    67 |         1 | 1100000 | 1000011 |
|      13 | 'F'   |    70 |         1 | 1001100 | 1000110 |
|      14 | 'G'   |    71 |         2 |  110101 | 1000111 |
|      15 | 'I'   |    73 |         1 |  101110 | 1001001 |
|      16 | 'J'   |    74 |         3 |    1010 | 1001010 |
|      17 | 'K'   |    75 |         3 |   10010 | 1001011 |
|      18 | 'O'   |    79 |         1 | 1010001 | 1001111 |
|      19 | 'P'   |    80 |         2 |  110010 | 1010000 |
|      20 | 'U'   |    85 |         2 |  101010 | 1010101 |
|      21 | 'W'   |    87 |         1 | 1100010 | 1010111 |
|      22 | 'Y'   |    89 |         1 | 1001101 | 1011001 |
|      23 | 'b'   |    98 |         1 | 1010000 | 1100010 |
|      24 | 'e'   |   101 |         1 | 1100011 | 1100101 |
|      25 | 'j'   |   106 |         1 |   10110 | 1101010 |
|      26 | 'k'   |   107 |         2 |  101001 | 1101011 |
|      27 | 'm'   |   109 |         5 |   11101 | 1101101 |
|      28 | 'n'   |   110 |         1 | 1001110 | 1101110 |
|      29 | 'q'   |   113 |         1 | 1001111 | 1110001 |
|      30 | 'v'   |   118 |         2 |  111000 | 1110110 |
|      31 | 'w'   |   119 |         1 | 1010110 | 1110111 |
|      32 | 'z'   |   122 |         1 | 1010111 | 1111010 |
+---------+-------+-------+-----------+---------+---------+

Huffman has a static cost, the Huffman table. On the other side, algorithms of the Lempel-Ziv family have very good compression and performance.

If your string is going to be english text you better use Smaz: https://github.com/antirez/smaz/tree/master

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM