Regarding your code, your problem is that your input is hex-encoded, but you decode it as bytes.
A simple fix would be replacing this line: let cryptedInput = toByteSeq(encryptedInput) ... with this: let cryptedInput = cast[seq[byte]](parseHexStr(encryptedInput)) and importing std/strutils for the parseHexStr. Mind you that casting is generally frowned upon, but so is copying memory from unsafeAddrs like you seem to be already doing.