fix encrypt bugs