unknown encoding: rot13

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
srksrk 68
Newbie
Posts: 24
Joined: Fri Jul 19, 2019 8:10 pm
Contact:

unknown encoding: rot13

#1 Post by srksrk 68 » Wed Jan 15, 2020 6:01 am

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!

User avatar
gas
Miko-Class Veteran
Posts: 838
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: unknown encoding: rot13

#2 Post by gas » Wed Jan 15, 2020 8:46 am

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.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Remix
Eileen-Class Veteran
Posts: 1591
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: unknown encoding: rot13

#3 Post by Remix » Wed Jan 15, 2020 12:17 pm

Try changing the

Code: Select all

text = text.encode("rot13")
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
Last edited by Remix on Wed Jan 15, 2020 12:23 pm, edited 1 time in total.
Frameworks & Scriptlets:

srksrk 68
Newbie
Posts: 24
Joined: Fri Jul 19, 2019 8:10 pm
Contact:

Re: unknown encoding: rot13

#4 Post by srksrk 68 » Wed Jan 15, 2020 12:22 pm

Remix wrote:
Wed Jan 15, 2020 12:17 pm
Try changing the

Code: Select all

text = text.encode("rot13")
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 ;)

srksrk 68
Newbie
Posts: 24
Joined: Fri Jul 19, 2019 8:10 pm
Contact:

Re: unknown encoding: rot13

#5 Post by srksrk 68 » Wed Jan 15, 2020 6:30 pm

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!

User avatar
Remix
Eileen-Class Veteran
Posts: 1591
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: unknown encoding: rot13

#6 Post by Remix » Thu Jan 16, 2020 2:10 pm

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
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]