Skip to content

Commit 5ea0098

Browse files
committed
Added codec: gila7
1 parent 6be082b commit 5ea0098

5 files changed

Lines changed: 51 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ This category also contains `ascii85`, `adobe`, `[x]btoa`, `zeromq` with the `ba
368368
- [X] `feron74`: aka FERON-74 (Base64 with a shuffled alphabet, from online JavaScript tools)
369369
- [X] `foursquare`: aka Four-square Cipher (bigrams substituted with two keyed squares and two plain ones)
370370
- [X] `fractionated-morse`: aka Fractionated Morse Cipher (Morse code split into groups of three symbols, each replaced by a letter of a keyed alphabet)
371+
- [X] `gila7`: aka GILA7 (Base64 with a shuffled alphabet, from online JavaScript tools)
371372
- [X] `gronsfeld`: aka Gronsfeld Cipher (variant of Vigenere Cipher with a numeric key)
372373
- [X] `hill`: aka Hill Cipher (blocks of letters multiplied by a key matrix modulo 26)
373374
- [X] `nihilist`: aka Nihilist Cipher (sums of the Polybius coordinates of the text and of a repeated key)

‎docs/pages/enc/crypto.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,23 @@ The text is converted to Morse code, with "x" between the characters, "xx" betwe
475475

476476
-----
477477

478+
### GILA7
479+
480+
This toy cipher comes from online JavaScript encryption tools. Like [ATOM-128](#atom-128), it is Base64 with a shuffled alphabet, whose 65th character (`G`) is used for padding, and the text is first escaped with JavaScript's `escape()`, then unescaped after decoding.
481+
482+
**Codec** | **Conversions** | **Aliases** | **Comment**
483+
:---: | :---: | --- | ---
484+
`gila7` | text <-> GILA7 ciphertext | `gila-7`, `gila_7` |
485+
486+
```python
487+
>>> codext.encode("this is a test", "gila7")
488+
'3+1QqbzbB+Odcg=5v0zbBWfOqxyG'
489+
>>> codext.decode("3+1QqbzbB+Odcg=5v0zbBWfOqxyG", "gila-7")
490+
'this is a test'
491+
```
492+
493+
-----
494+
478495
### Gronsfeld Cipher
479496

480497
This is a variant of the [Vigenere Cipher](#vigenere-cipher) whose key is made of digits, each digit giving the shift of a letter (0 to 9). There is no default key, meaning that `gronsfeld` as the encoding scheme throws a `LookupError` indicating that the _key must be a non-empty numeric string_.

‎src/codext/crypto/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .feron74 import *
2020
from .foursquare import *
2121
from .fractionatedmorse import *
22+
from .gila7 import *
2223
from .hill import *
2324
from .nihilist import *
2425
from .playfair import *

‎src/codext/crypto/_jsbase64.py‎

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

‎src/codext/crypto/gila7.py‎

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

Comments
 (0)