encryption refactor,add missing comments