I have a question about the chi-square test How can we use it in cryptography? And what results should we expect from it when a file is encrypted? I mean, when a file is encrypted, should its value increase?
$\chi^2$ measures the uniformity of a sample distribution. It's commonly used to test samples for randomness (I don't want any hassle on this), to do with true and pseudo random number generators. Uniformity is absolutely necessary for cryptography which you can read about elsewhere herein.
$dd if=/dev/urandom of=/tmp/urandom bs=1000 count=1000 $ent /tmp/urandom Entropy = 7.999799 bits per byte. Optimum compression would reduce the size of this 1000000 byte file by 0 percent. Chi square distribution for 1000000 samples is 278.05, and randomly would exceed this value 15.37 percent of the times. Arithmetic mean value of data bytes is 127.3541 (127.5 = random). Monte Carlo value for Pi is 3.141468566 (error 0.00 percent). Serial correlation coefficient is 0.000781 (totally uncorrelated = 0.0).
A mean value is about 255 for an eight bit window (byte) if a thing is randomesque, or properly encrypted. So yes, generally the thing's information entropy increases to ~8 bits/byte or ~1 bit/bit when encrypted.