encrypt bug fix, add decrypt

Fixed a bug in the encrypt function (Still doesn't act the same way as
the c# version), disable some debug lines, add a matching decrypt
function.