I have a phone database /data/user/0/com.miui.gallery/databases/gallery.db containing information such as exif data and file name. there is a column sha1 containing value


I lost the phone and MicroSD Card so the original files are lost. However there is a cache directory /storage/emulated/0/Android/data/com.miui.gallery/files/gallery_disk_cache/full_size containing thumbnails in 750x1000 resolution.

I identified a picture which is the preview for the above entry. However the file name cannot be found in the database. also the mtime is slightly different, although I am sure that is the same picture.

the file name of the thumbnail picture is (I don't know what it is)


the calculated sha1 and sha2 of the thumbnail picture is


assuming the thumbnail file name is the sha2 of the original picture, is there any way to assign the sha2 to sha1 without having the file? maybe with bruteforce or something?

  • 1
    If the file name in gallery.db with or without path? Because assuming the contained SHA-1 value is from the original image file it doesn't make sense to lookup the thumbnail by the hash of the original file data hash. Calculating the hash is pretty CPU intensive, especially for JPEG images it may be faster to load the JPEG image directly in a lower resolution than calculating the hash for looking up the thumbnail.
    – Robert
    Mar 9, 2023 at 10:48
  • @Robert how does the app know which thumbnail to use?
    – alecxs
    Mar 9, 2023 at 12:18
  • The fastes way would be to use the file path and meta data like last modified and lookup this in gallery.db. It is possible that the thumbnail file-name hash is not on the picture content but on its file-name and meta-data. To see how the database and the thumbnails are generated I would try to decompile the gallery app.
    – Robert
    Mar 9, 2023 at 13:18
  • I also have a snapshot of the disk, so I have the file metadata. But I don't know how to look at on f2fs file system. However I have uploaded example database here
    – alecxs
    Mar 13, 2023 at 20:00


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.