Fix function for encrypting archives to handle trailing slashes