jwkrahn has asked for the wisdom of the Perl Monks concerning the following question:
I was just reading a CRYPTO-GRAM article about rot8000 and was wondering if anyone was working on a Perl implementation?
FWIW, Google was no help.
Update:
|
---|
Replies are listed 'Best First'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Re: ROT8000 implementation?
by LanX (Saint) on Oct 15, 2021 at 21:45 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This would only work for old and obsolete UCS-2 with only 0x10000 = 2^16 code-points.° implementation should be straightforward: For each character:
Cheers Rolf °) Because by definition is rot self inverting: rot(rot(x))=x resp. rot^2=id | [reply] [d/l] [select] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
by atcroft (Abbot) on Oct 16, 2021 at 01:13 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Actually, my understanding has always been that ROT-N is just a notation for a Caesar cipher with a specified N. ROT13 is the case of a Caesar cipher rotated by 13d characters, which when using the 26d (2d*13d) character Latin alphabet means that rot(rot(x, 13d), 13d)=x. For any other N, deciphering would be the case of using (26d-N), or rot(rot(x, N), (26d-N))=x. Extending this further, giving a ROT-N of an M-character alphabet, this becomes rot(rot(x, N), (M-N))=x. If N is larger than M, the encoding can be simplified to (N % M) and decoding to (M - (N % M)) (thus if M=26d, ROT-53d simplifies to ROT-1d, decoded by ROT-25d). I have never heard of ROT-N notation being in anything but decimal (but that may also be my lack of exposure). As far as the most common encodings (UTF-8, UTF-16, and UTF-32), all support the 1_112_064d Unicode code points currently defined. Thus an N value of 556_032d (hex: 0x8_7C00) should result in the equivalent behavior for the existing defined code points to the ROT-13d with the 26d-character Latin alphabet (i.e., a self-decoding function). Below are the encoding and decoding rotations for a 26d, 256d, and 1_112_064d character "alphabets" for various N. It should be noted using 0x8000 (32_768d) rotations on a 256-character alphabet is the equivalent of "double ROT-13d encoding" on a 26-character alphabet, and that using the current number of code points (1_112_064d) has the effect on both a 256-character and 1_112_064-character alphabet. (If you find an error in my logic or values, please advise, so I can correct my understanding and/or data, as appropriate.)
Hope that helps. | [reply] [d/l] [select] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
by LanX (Saint) on Oct 16, 2021 at 08:19 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There is no formula with fixed N here because it operates with a 2^16 lookup table to avoid non-printable characters in both directions.
EditSo the actual N(X) for a mapping Y=R(X) N(X)= N(Y)= Y-X will vary near approximately 2^15-20+-8 (?).* And it ignores anything >= 2^16 like emojis, similar to ROT13 ignoring any ASCII outside the alphabet.
Cheers Rolf *) Actually the description of the author was outdated and doesn't fit his code. He's excluding 2100 characters. | [reply] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
by LanX (Saint) on Oct 15, 2021 at 23:47 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AFAIS So not just a simple rotate by 0x8000 = 2^15! One needs This JS implementation should be a good start for a Perl port https://github.com/rottytooth/rot8000/blob/main/rot8000.js You can use ord and chr to convert to codepoint and back HTH!
Cheers Rolf | [reply] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: ROT8000 implementation?
by Takeshi Kovacs (Beadle) on Oct 16, 2021 at 16:30 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FYI: # $chinese = "籝籱籮 籫籾籽籵籮类 籭籲籭 籲籽簪"
| [reply] [d/l] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: ROT8000 implementation?
by karlgoethebier (Abbot) on Oct 16, 2021 at 13:53 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If you really want to do this why don’t you port some code from GitHub you linked to to Perl? Read more... (3 kB)
«The Crux of the Biscuit is the Apostrophe» | [reply] [d/l] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
by Anonymous Monk on Oct 16, 2021 at 15:00 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Your post adds nothing new to the thread, or do you want to show us your implementation? | [reply] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
by karlgoethebier (Abbot) on Oct 16, 2021 at 17:07 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
«…show us your implementation?» Why should I? The OP himself linked to an implementation. If this implementation is good or valid or what ever you like is another question. And it is a good and common practice to port some algorithm from one language to another. See Rosetta Code for some examples. «The Crux of the Biscuit is the Apostrophe» | [reply] |