• for a start

    you have declared @Result as VARCHAR(MAX) so why are you converting to NVARCHAR(MAX) and so then forcing a further implicit conversion to VARCHAR(MAX)

    I'd also suggest checking what the return type is for the EncryptByKey function called in function Encrypt to see if that also needs to be converted.

    The error relates to something being converted to VARBINARY so check any assignments to variables of that type