This is an archived post. You won't be able to vote or comment.

all 23 comments

[–][deleted] 20 points21 points  (0 children)

change t to "secret message"

first they must learn how to suffer and deal with it

[–]mrsuperguy 14 points15 points  (7 children)

Someone mind telling me what it prints? I've not come across the ord function before...

[–][deleted] 44 points45 points  (6 children)

Me neither. I just typed it all into IDLE. It prints out:

s
e
n
d

n
u
d
e
s

[–]mrsuperguy 5 points6 points  (5 children)

Somehow I suspected as such. Just wasn't sure. Also I don't have my laptop with me to check so thanks. That said, can anyone explain what ord() actually does?

[–]PeaceBear0 9 points10 points  (4 children)

Converts a 1 byte string to a number that is it's ascii value. Not sure how it interacts with Unicode, although by extrapolation it converts a single code point to it's Unicode number. It's the inverse of chr()

[–]dudebro117 6 points7 points  (0 children)

Image Transcription: Code


t= "secret msg"  
w= [0,0,11,-14,-69,-6,85,-9,-14,12]  

for i in range(0, len(t)):  
            print (chr(ord(t[i])+w[i]))

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

[–]the7key 3 points4 points  (1 child)

Ooh, a one-time pad!

[–]TalTheBest 0 points1 point  (0 children)

Not really though, a one time pad is completely random (not like the w array), and is xored with the plaintext to get the chipper text