fixed and made the $key optional in encode() of encrypt_library