Decipher a Vigenère ciphertext
Golfscript -- 48 chars
n%~.,@*\{\(123,97>91,65>+58,48>+:|?@|?\-|=}%\0<+
No tricks in this one!
MS-DOS 16bit .COM file - 87 bytes
Base64 encoded binary (following this link for a decoder)
v1cBi8/oQACJ/ovv6DkAi9msitAqF3MDgMI+gMJhgPp6dguA6jqA+lp2A4DqK80hO/d0IkM563TW69YsYXMIBCB9AgQrBBqqtAHNITwNdev+xLIKzSHD
APL (45)
∆[⍙⍳⍨¨⌽∘∆¨(⍴⍙←⍞)⍴1-⍨⍞⍳⍨∆←⎕D,⍨⎕A,⍨⎕UCS 96+⍳26]
Explanation:
∆←⎕D,⍨⎕A,⍨⎕UCS 96+⍳26
: generate the alphabet (numbers (⎕D
) follow letters (⎕A
) follow lowercase letters (⎕UCS 96+⍳26
, the unicode values from 97 to 122).1-⍨⍞⍳⍨∆
: read a line (the key), find the position of each character in the alphabet, and subtract one (arrays are one-based by default, so shifting by those values directly would shift the alphabet one too far).(⍴⍙←⍞)⍴
: read another line (the message), and repeat the indices of the key so that it has the length of the message.⌽∘∆¨
: rotate the alphabet by the indices belonging to the key⍙⍳⍨¨
: look up each character in the message in the corresponding shifted alphabet∆[
...]
: look up the given indices in the normal alphabet, giving the corresponding characters.