decoding algorithm wanted

前端 未结 5 1327
礼貌的吻别
礼貌的吻别 2021-01-21 06:55

I receive encoded PDF files regularly. The encoding works like this:

  • the PDFs can be displayed correctly in Acrobat Reader
  • select all and copy the test vi
5条回答
  •  我在风中等你
    2021-01-21 07:25

    You need to brute-force it.

    If those patterns are simple like +2 character code like in your examples (which is +2 char codes)

    h i j
    e f g
    l m n
    l m n
    o p q
    
    1 2 3
    3 4 5
    5 6 7
    7 8 9
    9 : ;
    

    You could easily implement like this to check against knowns words

    >>> text='jgnnq'
    >>> knowns=['hello', '13579']
    >>>
    >>> for i in range(-5,+5): #check -5 to +5 char code range
    ...     rot=''.join(chr(ord(j)+i) for j in text)
    ...     for x in knowns:
    ...         if x in rot:
    ...             print rot
    ...
    hello
    

提交回复
热议问题