Fix APG legacy encryption