|
| 1 | +# -*- coding: UTF-8 -*- |
| 2 | +"""GILA7 Codec - GILA7 content encoding. |
| 3 | +
|
| 4 | +GILA7 is a toy cipher found on online JavaScript encryption tools. It is Base64 with a shuffled alphabet, whose 65th |
| 5 | + character ("G") is used for padding. As in the original JavaScript, the text is first escaped with JavaScript's |
| 6 | + escape() (e.g. " " becoming "%20" and "é" becoming "%E9"), and unescaped after decoding ; ciphertexts made without this |
| 7 | + escaping (i.e. from the UTF-8 bytes of the text) are then decoded the same way. |
| 8 | +
|
| 9 | +This codec: |
| 10 | +- en/decodes strings from str to str |
| 11 | +- en/decodes strings from bytes to bytes |
| 12 | +- decodes file content to str (read) |
| 13 | +- encodes file content from str to bytes (write) |
| 14 | +
|
| 15 | +Reference: http://qbarbe.free.fr/crypto/eng_gila7c.php |
| 16 | +""" |
| 17 | +from ._jsbase64 import js_base64 |
| 18 | +from ..__common__ import add |
| 19 | + |
| 20 | + |
| 21 | +__examples__ = { |
| 22 | + 'enc(gila7|gila-7|gila_7)': {'this is a test': "3+1QqbzbB+Odcg=5v0zbBWfOqxyG", 'test': "3+Ad37GG", '': ""}, |
| 23 | + 'dec(gila7)': {'3+Ad37GG': "test", '3+Ad 37GG': "test", '3+Ad37G': None, '3+Ad37G%': None}, |
| 24 | + 'enc-dec(gila7)': ["this is a test", "Hello, World! 1234", "\xe9t\xe9 ☃ \U0001F600", "100% sure", "a"], |
| 25 | +} |
| 26 | +__guess__ = ["gila7"] |
| 27 | + |
| 28 | + |
| 29 | +add("gila7", *js_base64("gila7", "7ZSTJK+W=cVtBCasyf0gzA8uvwDEq3XH/1RMNOILPQU4klm65YbdeFrx2hij9nopG"), r"^gila[-_]?7$", |
| 30 | + printables_rate=1., expansion_factor=(1.6, .3)) |
0 commit comments