DEV Community

Discussion on: A unicode substitution cipher algorithm

Collapse
 
dwd profile image
Dave Cridland • Edited

>>> u''.join([ c if c == ' ' else unichr(ord(c) - 0x2352 + ord('A')) for c in s ])

I can never resist these things.

The three letter words were helpful - there's limited options there, so I thought aiming for an AND or a THE would be a good crib. The fact that you've left spaces unencoded does, of course, make this much simpler.

I do get, though, that this article isn't about cryptography. :-)

Collapse
 
victoria profile image
Victoria Drake

Python3:

''.join([ c if c == ' ' else chr(ord(c) - 0x2352 + ord('A')) for c in s ])

I love this. Let's be secret code buddies.

Collapse
 
dwd profile image
Dave Cridland

⍢⎄⎁⍴⌽⌯⍙⎄⎂⎃⌯⎁⍴⍼⍴⍼⍱⍴⎁⌯⎃⍾⌯⍴⍽⍲⍾⍳⍴⌯⎈⍾⎄⎁⌯⎂⍿⍰⍲⍴⎂⌯⍽⍴⎇⎃⌯⎃⍸⍼⍴⌽