Skip to content

Commit a9ff116

Browse files
committed
Improved codec: rot
1 parent a1155a6 commit a9ff116

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

codext/crypto/rot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
__guess1__ = ["rot-%d" % i for i in range(1, 26)] + ["rot-47"]
3232
__guess2__ = ["progressive-rot-%d" % i for i in range(1, 26)] + ["progressive-rot-n%d" % i for i in range(1, 26)]
33-
__guess3__ = ["alternative-rot-%d" % i for i in range(1, 26)]
33+
__guess3__ = ["alternative-rot-%d" % i for i in range(1, 26) if i != 13]
3434

3535

3636
ROT47 = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
@@ -90,7 +90,8 @@ def decode(text, errors="strict"):
9090
return decode
9191

9292

93-
add("alternative-rot", arot_encode, arot_decode, r"a(?:lt(?:ernative)?-)?(?:caesar|rot)[-_]?([1-9]|1[0-9]|2[0-5])$",
93+
# note: alternative-rot-13 is equivalent to rot-13, therefore excluded from the regex
94+
add("alternative-rot", arot_encode, arot_decode, r"a(?:lt(?:ernative)?-)?(?:caesar|rot)[-_]?([1-9]|1[0-24-9]|2[0-5])$",
9495
penalty=.2, entropy=lambda e: e, printables_rate=lambda pr: pr, transitive=True, examples=__examples3__,
9596
guess=__guess3__)
9697
add("rot", rot_encode, rot_decode, r"(?:caesar|rot)[-_]?([1-9]|1[0-9]|2[0-5]|47)$", aliases=["caesar"], penalty=.2,

0 commit comments

Comments
 (0)