An isolated smart grid with energy flow optimization and high energy quality has developed as the next-generation electricity grid. An isolated smart grid has more number of regular power frameworks and will become a new foundation for power systems and executives. Protecting the isolated smart grids from security threats is an important issue. Replay attack is one of the security threats for isolated smart grids, in which the data transmission is fraudulently delayed. This paper proposes using HMAC-MD5 algorithm a solution to detect replay attack. Further, HMAC-MD5 algorithm is compared to other existing algorithms, and the proposed algorithm is proved better with respect to key generation time and running time. © Springer Nature Singapore Pte Ltd 2021.