Skip to content

Commit 6be082b

Browse files
committed
Added codec: feron74
1 parent 6101081 commit 6be082b

5 files changed

Lines changed: 50 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ This category also contains `ascii85`, `adobe`, `[x]btoa`, `zeromq` with the `ba
365365
- [X] `enigma`: aka Enigma machine (Enigma I, M3 and M4, with reflector, rotors, rings, positions and plugboard)
366366
- [X] `esab46`: aka ESAB-46 (Base64 with a shuffled alphabet, from online JavaScript tools)
367367
- [X] `ezip64`: aka EZIP-64 (variant of ARMON-64 with smaller blocks)
368+
- [X] `feron74`: aka FERON-74 (Base64 with a shuffled alphabet, from online JavaScript tools)
368369
- [X] `foursquare`: aka Four-square Cipher (bigrams substituted with two keyed squares and two plain ones)
369370
- [X] `fractionated-morse`: aka Fractionated Morse Cipher (Morse code split into groups of three symbols, each replaced by a letter of a keyed alphabet)
370371
- [X] `gronsfeld`: aka Gronsfeld Cipher (variant of Vigenere Cipher with a numeric key)

‎docs/pages/enc/crypto.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,23 @@ This toy cipher, a variant of [ARMON-64](#armon-64), comes from online JavaScrip
418418

419419
-----
420420

421+
### FERON-74
422+
423+
This toy cipher comes from online JavaScript encryption tools. Like [ATOM-128](#atom-128), it is Base64 with a shuffled alphabet, whose 65th character (`4`) is used for padding, and the text is first escaped with JavaScript's `escape()`, then unescaped after decoding.
424+
425+
**Codec** | **Conversions** | **Aliases** | **Comment**
426+
:---: | :---: | --- | ---
427+
`feron74` | text <-> FERON-74 ciphertext | `feron-74`, `feron_74` |
428+
429+
```python
430+
>>> codext.encode("this is a test", "feron74")
431+
'sbxMC161WbyZ/rSiNq61WcDyCnA4'
432+
>>> codext.decode("sbxMC161WbyZ/rSiNq61WcDyCnA4", "feron-74")
433+
'this is a test'
434+
```
435+
436+
-----
437+
421438
### Four-square Cipher
422439

423440
The Four-square cipher, invented by Felix Delastelle, substitutes pairs of letters using four squares arranged in a 2x2 matrix: the upper-left and lower-right ones hold the alphabet in order, while the upper-right and lower-left ones are filled with two keywords. The first letter of each pair is located in the upper-left square and the second one in the lower-right square ; they are replaced by the letters at the other corners of the rectangle they form (in the upper-right square, then in the lower-left one).

‎src/codext/crypto/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .enigma import *
1717
from .esab46 import *
1818
from .ezip64 import *
19+
from .feron74 import *
1920
from .foursquare import *
2021
from .fractionatedmorse import *
2122
from .hill import *

‎src/codext/crypto/_jsbase64.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: UTF-8 -*-
2-
"""Base64 variants, shared by the toy ciphers of online JavaScript encryption tools (ATOM-128, ESAB-46).
2+
"""Base64 variants, shared by the toy ciphers of online JavaScript encryption tools (ATOM-128, ESAB-46, FERON-74).
33
44
These ciphers are Base64 with a shuffled alphabet of 65 characters, whose last one is used for padding. As in the
55
original JavaScript, the text is first escaped with JavaScript's escape() (e.g. " " becoming "%20" and "é" becoming

‎src/codext/crypto/feron74.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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

Comments
 (0)