The invention relates to a method for encoding MSR (Minimum-storage Regenerating) codes, which comprises the following steps of: acquiring n first data packets which are represented by Si, i=1, 2, . . . , n; setting n storage nodes and a positive integer k, wherein n=2K; respectively adding a specified number of 0 bits on data heads or data tails of subsequent successive k first data packets by taking the next first data packet of the ith first data packet as a starting point, acquiring k second data packets, and acquiring an encoded data packet by computing the k second data packets; repeating the above steps and acquiring n encoded data packets which are represented by Pi, i=1, 2, . . . , n; and storing the ith first data packet and the encoded data packet acquired by taking the next first data packet of the first data packet as the starting point into the ith storage node.