Ruby (200200 185)
sample runs + wc:
$ ruby onetimepad.rb
ENCRYPTENCODE
AAZZHELLOWORLDANOTHERTESTINPUTZZZ
CJGTEFEDXEZUERZYCLGHDWLDASFUTHWKC
CJFSLJPOLANLPUBPMIBXOXTPTQIVBMDPX
$ ruby onetimepad.rb
DECRYPTDECODE
CJGTEFEDXEZUERZYCLGHDWLDASFUTHWKC
CJFSLJPOLANLPUBPMIBXOXTPTQIVBMDPX
AAZZHELLOWORLDANOTHERTESTINPUTZZZ
$ wc onetimepad.rb
24 37 200185 onetimepad.rb
f=->k,p,o{p.scan(r=/./).zip(k.scan r).map{|a|a.map{|b|b.ord-65}.inject(o)}.map{|c|(c%26+65).chr}*''}
puts(gets[0]==?D?(k=gets;f[k,gets,:-]):[k=(2..(p=gets).size).map{(65+rand(26)).chr}*'',f[k,p,:+]])
and with newlines and indents (still not very readable)
f=->k,p,o{
p.scan(r=/./).zip(k.scan r).map{|a|
a.map{|b|b.ord-65}.inject(o)
}.map{|c|
(c%26+65).chr
}*''
}
puts(gets[0]==?D ?
(k=gets;f[k,gets,:-])
: [k=(2..(p=gets).size).map{
(65+rand(26)).chr
}*'',
f[k,p,:+]])
def f;gets.scan(/./).map{|b|b.ord-65};end
s=->a{a.map{|b|(b+65).chr}*''}
r=->b,a,o{s[a.zip(b).map{|a,b|(a.send o,b)%26}]}
puts(gets=~/^D/?r[f,f,:+]:[s[k=(p=f).map{rand 26}],r[k,p,:-]])