In this paper, we consider the privacy preservation problem in both discrete-and continuous-time average consensus algorithms with strongly connected and balanced graphs, against either internal honest-but-curious agents or external eavesdroppers. A novel algorithm is proposed, which adds edge-based perturbation signals to the process of consensus computation. Our algorithm can be divided into two phases: a coordinated scrambling phase, which is for privacy preservation, and a convergence phase. In the scrambling phase, each agent is required to generate some perturbation signals and add them to the edges leading out of it. In the convergence phase, the agents update their states following a normal updating rule. It is shown that an internal honest-but-curious agent can obtain the privacy of a target agent if and only if no other agents can communicate with the target agent. As for external eavesdroppers, it is proved that this kind of attackers can never obtain any agent's privacy.