The invention belongs to the technical field of passwords, and specifically relates to an order-preserving encryption algorithm based on a balanced sort tree storage structure. In the order-preservingencryption algorithm, a data storage basic structure comprises an AVL tree, a red-black tree, a B tree, a B+ tree or a B* tree; and different data storage structures have slightly different algorithmexpressions. The algorithm takes an AVL tree structure as an example, and comprises a basic AVL tree-based ideal secure order-preserving encryption algorithm and some improved order-preserving encryption algorithms. Various algorithms are described from a tree structure, an initialization algorithm, an encryption algorithm, a decryption algorithm, an orderby sort algorithm, a range query algorithm, a deletion algorithm, a balancing algorithm and an interactive query algorithm. Compared with most order-preserving encryptions that cannot achieve the ideal secure effect, the algorithm security provided by the invention has absolute advantages, the algorithm provided by the invention also performs all-directional comparison, and the algorithm is suitable for most systems and is especially suitable for a system with relatively high security requirements and sufficient bandwidth configuration.