Blockchain technology, due to its decentralized, traceable, and tamper-resistant characteristics, has been applied in a wide range of collaborative computing scenarios, including smart grid, industrial production, and smart cities. Consensus algorithm, as the key blockchain technology, plays a decisive role in terms of performance, security, and scalability, ensuring that system nodes reach consensus on transaction data. However, with the increase of user nodes and the diversity of application scenarios, existing consensus algorithms face some performance and security challenges. To overcome these challenges, this article proposes a novel blockchain consensus mechanism, namely the Reputation-Aware Randomization Consensus Algorithm (RRCA). The proposed mechanism first constructs a dynamic reputation evaluation model to divide nodes into ordinary ones and candidate ones. Secondly, a selection model is constructed for candidate nodes to select consensus nodes, which run the consensus algoritlun. Finally, a random selection mechanism for the leader node of the proposed consensus algorithm is constructed to ensure the unpredictability and reduce the probability of the leader node being subjected to malicious attacks. Theoretical analysis and experimental results indicate that the RRCA can significantly reduce consensus latency and increase the unpredictability of the leader node, which improves the performance and security of blockchain systems.