The invention relates to a coding and decoding method and a dual-mode coding and decoding method based on a Hash-fractal image chain, and the method comprises the steps: segmenting a text into blocks according to a set number of characters when the length of the text is greater than a threshold value, and generating a Hash value chain for each block through SHA-256; intercepting the first 16 bytes of the hash value of each block to generate a hippeastrum set image, then generating a binary fractal image, embedding
metadata dot matrixes into four corners of the fractal image, and storing the
metadata dot matrixes in sequence; traversing the target folder, obtaining all PNG images, and sorting the PNG images according to file name indexes; for each image, extracting
metadata areas in sequence and decoding the metadata areas, firstly verifying fractal dimension errors of the image to ensure that a carrier is complete, then checking the consistency of each prevhashframe and a previous nexhashframe, positioning a chained tampering position, recalculating a CRC8
checksum, comparing with a storage value and marking a damaged data block; and finally, splicing effective data according to a block position sequence, and outputting a complete text and an abnormal mark. According to the method, the unlimited-capacity ordered associated storage breakthrough can be realized, and the tamper-resistant capability is improved.