Hamed Ben Ali Lucas, Secretary to the Prince of Barbary