Use some checksum / m5 lua libraries, there is some on github
https://github.com/kikito/md5.lua
https://github.com/philanc/plc/tree/master/plc
I didn't tets it but the main idea is that it will output a unique string from a file,
so if two files are two different, it will output diffeent strings.
You only need to make a string comparison based on that.