pyfsig
A python library for identifying files by headers (magic bytes). You may notice that on MS windows systems files will not open properly if you change the file extension, this is becuase MS windows only pays attention to the file header. Magic bytes/file headers serve as a way to discover the type of file without using the file extension. This library was written to assist python programmers in identifying what type of file something is from its magic bytes/file header. It was originally written by the author to reconstruct BLOB's from a legacy database which did not store the original file extensions.
based on info from: 'Wikipedia - List of file signatures'
Usage
The libraries use should fairly self explainatory, here are some examples:
Find matches for a file when you have the file path
file_path = "some/file/path.abc"
matches = find_matches_for_file_path(file_path=file_path)
Find matches for a file header you have read yourself
[!IMPORTANT] The "rb" here is very important, you must read the file as "bytes"!
with open(file_path, "rb") as f:
file_header = f.read(32)
matches = find_matches_for_file_header(header=file_header)
Find matches against your own list of file signatures
You will need to create a FileSignatureDict with atleast the following keys:
file_extensionhexoffset
custom_signatures = [
{
"file_extension": "abc",
"hex": [1, 2, 3, None, 5],
"offset": 0,
}
]
file_path = "some/file/path.abc"
matches = find_matches_for_file_path(file_path=file_path, signatures=custom_signatures)
Alternatively, you can extend the built in file signatures with your custom file signatures.
from pyfsig import SIGNATURES
extended_signatures = [
*SIGNATURES,
{
"file_extension": "abc",
"hex": [1, 2, 3, None, 5],
"offset": 0,
}
]
file_path = "some/file/path.abc"
matches = find_matches_for_file_path(file_path=file_path, signatures=extended_signatures)
Contributors
Author: Patty C (schlerp)
Thanks to all contributors!!
Metadata
Release files for pyfsig 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyfsig-1.1.1.tar.gz | 41.3 kB | Without provenance | Details for pyfsig-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyfsig-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for pyfsig-1.1.1-py3-none-any.whl |
Total release size: 50.4 kB
Release files / pyfsig-1.1.1.tar.gz
| Download URL | pyfsig-1.1.1.tar.gz |
|---|---|
| Size | 41.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f9eddf1b8142285d2192645dc0e768dd1276ba9a7ae4984e41cd32720381ce4
|
|
BLAKE2b-256 checksum How to use checksums |
4e6f51deb68ed9fe45dea956c787f475000b8803abe86e6a6556ca22f48ca88b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.6.10
|
Release files / pyfsig-1.1.1-py3-none-any.whl
| Download URL | pyfsig-1.1.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c2e09c8a92502995338b6574978eebd8a096e56c8ea99fc296e8b78c78b4f458
|
|
BLAKE2b-256 checksum How to use checksums |
887c84908a696012d80a69fac0205c08a85797f3c9c94107fe30504eaaa538a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.6.10
|
Security for pyfsig 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.