|
| 1 | +# -*- coding: UTF-8 -*- |
| 2 | +"""FERON-74 Codec - FERON-74 content encoding. |
| 3 | +
|
| 4 | +FERON-74 is a toy cipher found on online JavaScript encryption tools. It is Base64 with a shuffled alphabet, whose 65th |
| 5 | + character ("4") 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_feron74c.php |
| 16 | +""" |
| 17 | +from ._jsbase64 import js_base64 |
| 18 | +from ..__common__ import add |
| 19 | + |
| 20 | + |
| 21 | +__examples__ = { |
| 22 | + 'enc(feron74|feron-74|feron_74)': {'this is a test': "sbxMC161WbyZ/rSiNq61WcDyCnA4", 'test': "sbRZs744", '': ""}, |
| 23 | + 'dec(feron74)': {'sbRZs744': "test", 'sbRZ s744': "test", 'sbRZs74': None, 'sbRZs74%': None}, |
| 24 | + 'enc-dec(feron74)': ["this is a test", "Hello, World! 1234", "\xe9t\xe9 ☃ \U0001F600", "100% sure", "a"], |
| 25 | +} |
| 26 | +__guess__ = ["feron74"] |
| 27 | + |
| 28 | + |
| 29 | +add("feron74", *js_base64("feron74", "75XYTabcS/UVWdefADqr6RuvN8PBCsQtwx2KLyz+OM3Hk9ghi01ZFlmnjopE=GIJ4"), |
| 30 | + r"^feron[-_]?74$", printables_rate=1., expansion_factor=(1.6, .3)) |
0 commit comments