implements encode method
writes crypted data to file (also refactors code)
realworld injects key and msg

key: original of DES key
     (NOTE: the length must be exactly 8 bytes)
msg: data to encrypt