Page 1 of 1
unknown encoding: rot13
Posted: Wed Jan 15, 2020 6:01 am
by srksrk 68
Hello Experts,
I am trying to do an unbreakable encryption of a dialog line with the rot13 cypher documented here:
https://www.renpy.org/doc/html/custom_t ... l#examples
However, neither the text tag {rot13} mentioned there, nor using function text.encode("rot13") directly work but give the error:
unknown encoding: rot13
I found other threads concerning rot13 in python (some importing codecs module, suggesting other methods, renaming to rot-13 or rot_13), but also no luck. Does anybody know how to do this without implementing the codec myself?
Many thanks!
Re: unknown encoding: rot13
Posted: Wed Jan 15, 2020 8:46 am
by gas
Mumble...
A dialogue line alone?
No need to devise a tag. Use a python shell and copy the result of rot-13 on a string.
UPDATE: verified by console that, for some reason, rot13 is actually not accessible not even listed in the codecs module. More probably, that example wasn't tested with recent releases.
Re: unknown encoding: rot13
Posted: Wed Jan 15, 2020 12:17 pm
by Remix
Try changing the
in the definition to
Code: Select all
text = renpy.translation.generation.rot13_transform(text)
# or
text = renpy.translation.generation.rot13_filter(text) # better for tags and interpolation
Note: Rot13 is not in any way unbreakable
Re: unknown encoding: rot13
Posted: Wed Jan 15, 2020 12:22 pm
by srksrk 68
Remix wrote: ↑Wed Jan 15, 2020 12:17 pm
Try changing the
in the definition to
Code: Select all
text = renpy.translation.generation.rot13_transform(text)
Thanks, will try that!
Note: Rot13 is not in any way unbreakable
Nooooo!
I knew that
Re: unknown encoding: rot13
Posted: Wed Jan 15, 2020 6:30 pm
by srksrk 68
OK, tried it and found out that rot13_transform is totally bugged. It contains no less than two typos that make it anything but the rot13 transformation:
Code: Select all
def rot13_transform(s):
ROT13 = { }
for i, j in zip("ABCDEFGHIJKLM", "NMOPQRSTUVWYZ"):
ROT13[i] = j
ROT13[j] = i
i = i.lower()
j = j.lower()
ROT13[i] = j
ROT13[j] = i
return "".join(ROT13.get(i, i) for i in s)
In fact, the parameters of the zip need to be ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ") to make it rot13.
So I went and implemented a combined rot13/rot5 to make it permutate digits as well. For those who are interested:
Code: Select all
def rot135_transform(s):
ROT135 = { }
for i, j in zip("ABCDEFGHIJKLM01234", "NOPQRSTUVWXYZ56789"):
ROT135[i] = j
ROT135[j] = i
i = i.lower()
j = j.lower()
ROT135[i] = j
ROT135[j] = i
return "".join(ROT135.get(i, i) for i in s)
Thanks for the help, though!
Re: unknown encoding: rot13
Posted: Thu Jan 16, 2020 2:10 pm
by Remix
I let Tom know about the rot13_transform and he has applied a fix (will be available in next main release)
Fixes to the documentation code are also on his agenda