The power grid is vulnerable to cyberattacks due to the multitude of utilized communication-based devices. For example, remote terminal units (RTU) communicate commands or grid measurements. An encryption and decryption method is one way of preventing cyberattacks. However, sophisticated encryption and decryption methods can be time-consuming due to the large amount of data exchanged in a power system. This paper combines a Duffing oscillator, a time-based one-time frequency (TOTF) algorithm, and fast Fourier transform for preventing cyberattacks. The proposed method detects when an attacker distorts data in a high-noise environment. The proposed method is validated using simulation results on a modified communication layer by enabling the quadrature phase shift keying (QPSK) digital modulation method to transfer packets.