How is Plex hash calculated?

There are a few steps:

  • Create a string with the filesize in decimal
  • Take the SHA1 hash of the first 64kB (65536 bytes) and append this to the string in hex.
  • If the file is greater than 64kB, do the same with the last 64kB
  • SHA1 hash this string

As an example, let’s look at a copy of Big Buck Bunny:

  • The file size is 928670754 bytes
  • The first 64kB has a SHA1 hash of 87a82ca143a5d84ba4ba33f421f25fbac9811f89
  • The last 64kB has a SHA1 hash of ce2f3dd83c1cc4ffa4deda5588a9118be004ce09
  • Take the SHA1 hash of 92867075487a82ca143a5d84ba4ba33f421f25fbac9811f89ce2f3dd83c1cc4ffa4deda5588a9118be004ce09
  • This is 782e3038c7290470c29320a840e5f92123912e56 which matches the hash column in the media_parts table if you add this exact file to it.
3 Likes