6 minute(s) de lecture

Simple file verification (SFV) is a file format for storing CRC32 checksums of files to verify the integrity of files. SFV is used to verify that a file has not been corrupted, but it does not otherwise verify the file’s authenticity. The .sfv file extension is usually used for SFV files. (wikipedia)

This project is composed of two script : sfv-generator.py and sfv-validator.py.

# sfv-generator

This tool enable you to generate SFV easily for your files. Let’s see how to use this script.

How to use it ?

First of all clone this repository.

# clone the repo
git clone git@github.com:zestones/sfv-tool.git

You can see how to use the program by executing this command:

# see how to use the script
python3 sfv-generator.py -h 

Options

Option Description
--help (-h) Show help
--file (-f) Provide a file
--directory (-d) Provide a folder
--outputfolder (-o) Specify a folder for the output
--outputfile (-O) Specify the a filename of the output
--separated (-s) Merge the output
--level (-l) Specify the search depth

Let’s see in details how to use these options.

Providing files

You can provide a file like below :

python3 sfv-generator.py -f myfile.ext

The SFV will be created in the folder of the provided file, if you want to redirect the output in a new or different folder add the option --output.

python3 sfv-generator.py -f myfile.ext -o ./myfolder/

You can also give a list of file :

python3 sfv-generator.py -f myfile-1.ext -f myfile-2.ext -o ./myfolder/

Then, you should have the following folder structure :

myfolder
│   myfile-1.sfv
│   myfile-2.sfv 

If you want to merge the the output you can add the --separated option :

python3 sfv-generator.py -s -f myfile-1.ext -f myfile-2.ext -o ./myfolder/

This way the output will be redirected inside an unique file, your folder structure will be :

myfolder
│   auto-generated.sfv

Providing Folders

If you want to generate SFV for all files inside a folder you can use the --directory option to provide a folder to the program.

The usage is the same as for the files, you can provide a unique folder or a list of folder. And merge the output if you want only one SFV file.

# generate SFV file for each file inside "./folder"
python3 sfv-generator.py -d ./folder

# generate SFV file for each file inside "./folder" and redirect the output to "./newFolder"
python3 sfv-generator.py -d ./folder -o ./newFolder

# generate SFV file for each file inside "./folder" and redirect the output to "./newFolder" (the output is merged in a single file)
python3 sfv-generator.py -s -d ./folder-1/ -d ./folder-2/ -o ./newfolder/

NOTE

When you don’t give an output the SFV files are created in the directory of the source file.

WARNING

If you provide multiple folders without an ouput directory there is two possibility :

1. You use the --separated option (-s) to merge the output, then the SFV will be created inside the parent folder.

2. You dont use the -s option, then each SFV will be created were the source file is located.

This warning apply only if you set the --level of search, otherwise the SFV will be generated inside the parent directory given in parameter.

By default the program search inside the folder provided but do not check the content of subfolders. If you have subfolders and want to generate SFV file for them you can provide the search depth with the --level option.

In the example below, the program will search to a depth of 2.

python3 sfv-generator.py -l 2 -d ./folder

Sometimes you may want to generate SFV files by providing a folder but not on all the files. You can filter the files by their extension, for that just use the --extension option.

As for the –file or the –directory option you can provide a list of extensions. This way you will generate SFV file for all the files inside the directory that has the extension specified.

# specify a file extension
python3 sfv-generator.py -e .zip -d ./folder

# specify a list of extension
python3 sfv-generator.py -e .zip -e .rar -e .tar -d ./folder

WARNING

This option should be used only with the --directory option (there is no use to use it with the --file option).

You might want, to change the default name of the generated files. When you merge the output the default name of the output file is “auto-generated”, if you want to change this name you can use the --outputfile option (-O).

# change the output filename
python3 sfv-generator.py -s -d ./folder -O newname

You can of course mix the --outputfile (-O) and --outputfolder (-o) options, to specify an output folder and an output file.

# change the output filename
python3 sfv-generator.py -s -d ./folder -o ./newfolder -O newname

The option --outputfile (-O) also work with the --file (-f) option.

Usage advice

  • Use the --help (-h) option to show how to use the program.
  • Note that the --level (-l) option should not be used with the option --file (-f).

    WARNING

    You should not mix -f and -d options.

    When providing a list of files or folders, be sure to add the -f or -d option before each file or folder.

    The --outputfile (-O) work only with the --separated option (-s).

sfv-validator

This tool enable you to check the integrity of files.

How to use it ?

# clone the repo
git clone git@github.com:zestones/sfv-tool.git

# move to the folder
cd ./sfv-tool/sfv-validator/

You can see how to use the program by executing this command:

# clone the repo
python3 sfv-validator.py -h

You have two possibility to check the integrity of files you can give the hash and a file to the program or give an .SFV file in parameter.

Options

Option Description
--help (-h) Show help
--file (-f) Provide a file
--crc (-c) Provide a file hash
--sfv (-s) Provide a SFV file
--depth (-d) Specify the search depth

Let’s see in details how to use these options.

#

Hash and Source file

If you have the hash of a given file you can check if your file is corrupted or not in the following way :

# check the integrity of a file
python3 sfv-validator.py -f myfile.txt -c the_hash

You can also give multiple files and hash in parameter by adding before each file the -f option and before each hash the -c option.

# check the integrity of a multiple file
python3 sfv-validator.py -f myfile1.txt -c hash1 -f myfile2.zip -c hash2

NOTE

The order is important when you write multiple files and hash, don’t mix the hashes and the files.

SFV file

Checking each file by writing it’s name and hash is long. Let’s see how to use the .SFV file to check the integrity of lots of files.

The --sfv (-s) option enable you to give an .SFV file in parameter. The program will read the file and check the integrity of each file inside it.

# check the integrity of files
python3 sfv-validator.py -s ./auto-generated.sfv

You can also provide multiple .SFV file.

# check the integrity of files
python3 sfv-validator.py -s ./auto-generated.sfv -s ./folder/auto-generated.sfv

NOTE

The files you are trying to check should be with the SFV file in the same folder.

If you used the sfv-generator tool, you have seen that you can give a --level of search. If you used this option, the files listed inside the .SFV are also located in subfolders. To check the integrity of files located in subfolders too, you should use the --depth option (-d).

# check the integrity of files
python3 sfv-validator.py -d -s ./folder/auto-generated.sfv

NOTE

If you don’t use the --depth option (-d) only the files inside the parent folder of the .SFV will be checked.

Usage advice

  • Use the --help option (-h) to show how to use the program.
  • Don’t mix the -f and -s options