In the process of crowdsensing, tasks allocation is an important part for the precise as well as the quality of feedback results. However, during this process, the applicants, the publisher and the authorized agency may aware the location of each other, and then threaten the privacy of them. Thus, in order to cope with the problem of privacy violation during the process of tasks allocation, in this paper, based on the basic idea of homomorphic encryption, an encrypted grids matching scheme is proposed (short for EGMS) to provide privacy preservation service for each entity that participates in the process of crowdsensing. In this scheme, the grids used for tasks allocation are encrypted firstly, so the task matching with applicants and publisher also in an encrypted environment. Next, locations used for allocation as well as locations that applicants can provide services are secrets for each other, so that the location privacy of applicants and publisher can be preserved. At last, applicants of task feedback results of each grid that they located in, and the publisher gets these results, and the whole process of crowdsensing is finished. At the last part of this paper, two types of security analysis are given to prove the security between applicants and the publisher. Then several groups of experimental verification that simulates the task allocation are used to test the security and efficiency of EGMS, and the results are compared with other similar schemes, so as to further demonstrate the superiority of proposed scheme.