Given a signal $ x[n] $ and its reverse
$xrev[n] = x[N - n - 1]$
The autocorrelation is defined to be the convolution $x[n]*xrev[n]$
$DFT(x) = X[k] = a + bi$
$DFT(xrev) = X^*[k] = a - bi$
$(a+bi)(a-bi) = a^2 + b^2$
$DFT(x*xrev[n]) = |X[k]|^2$
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0, 20*np.pi, 1000)
x = np.sign(np.sin(t))
x = np.concatenate((x, np.zeros(len(x))))
X = np.fft.fft(x)
XPow = np.real(X)**2 + np.imag(X)**2
xacorr = np.fft.ifft(XPow)
plt.subplot(211)
plt.plot(x[0:1000])
plt.subplot(212)
plt.plot(xacorr[0:1000])