如何最小化加密令牌?

时间:2015-07-16 04:29:23

标签: java encryption encoding blowfish stripping

我已经从Blowfish生成了加密令牌。例如: - 7$127O$137kI$137mK$07WK$01$26m$05zYbJmCmUw$16nF$11G$27A2Gv$19Jm8$26eJ9kUv$07$118q$05$02$24KP8j$208$16$06$100P$11

出于好奇,我能否以某种方式获得更多最小化/简化/条纹的令牌。可以做任何事情以使这更简化,可以是任何编码。请帮帮我。

由于

2 个答案:

答案 0 :(得分:1)

使用您的字符串尝试霍夫曼编码。对于字符串7$127O$137kI$137mK$07WK$01$26m$05zYbJmCmUw$16nF$11G$27A2Gv$19Jm8$26eJ9kUv$07$118q$05$02$24KP8j$208$16$06$100P$11

压缩率为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 |
+---------+-------+-------+-----------+---------+---------+

答案 1 :(得分:1)

霍夫曼有一个静态成本,霍夫曼表。另一方面,Lempel-Ziv系列的算法具有非常好的压缩和性能。

如果你的字符串是英文文本,你最好使用Smaz:https://github.com/antirez/smaz/tree/master