With the development of IoT technology, IoT devices have penetrated various fields, such as smart homes, industrial automation, healthcare, etc. However, the security issues of IoT devices have always troubled people. Attackers can use various means to attack IoT devices, such as stealing data, tampering with programs, malware infection, etc. These attack methods will bring great losses to users. In response to the above issues, this study uses proxy re-encryption technology to transform data collected by IoT devices into ciphertext. Then, it stores the encrypted IoT data on the blockchain. The combination of blockchain and proxy re-encryption technologies offers a method for the secure sharing of IoT data. The experimental results show that whether the algorithm encrypts a small or large amount of data, the encryption time is relatively short, and the time consumption does not exceed 15 ms. When encrypting 8196 bytes of data, its encryption time is 50% lower than the Attribute-Based Encryption (ABE) algorithm. The proposed IoT data security sharing method has the advantages of high security, fast encryption speed, and good stability, which helps to improve the security performance of the IoT and provides a new approach to IoT security.