Giter Club home page Giter Club logo

determine-archive-filetype's Introduction

determine archive filetype (not suitable to actual use)

determine an archive's filetype using common magic bytes (file signatures)

this is a very crude alternative to using python-magic, and libmagic that i used for learning purposes

included magic bytes (file signatures)

signature extension description
\x89\x50\x4e\x47\x0d\x0a\x1a\x0a png portable network graphics format
\x7b\x5c\x72\x74\x66\x31 rtf rich text format
\x4c\x5a\x49\x50 lz lzip compressed file
\x37\x7a\xbc\xaf\x27\x1c 7z 7-Zip file format
\xfd\x37\x7a\x58\x5a\x00 xz XZ compression utility using LZMA2 compression
\x1f\x8b\x08 gz GZIP compressed file
\x42\x5a\x68 bz2 compressed file using Bzip2 algorithm
\x50\x4b\x03\x04 zip zip file format and formats based on it like jar, xlsx, docx, apk, etc

requirements

Python v3.2+ because unicode is hard

status

development

example

$ python3 ./determine_archive_filetype.py
directory: /Users/josh/dev/python/determine-archive-filetype
file: test-doc.rtf, type: rtf
file: .DS_Store, type: no match
file: tar-cjf.tar.gz, type: bz2
file: screenshot.png, type: png
file: test-doc.docx.lz, type: lz
file: test.tar.xz, type: xz
file: test-zip.zip, type: zip
file: test-doc.docx.7z, type: 7z
file: test-doc.docx, type: zip
file: determine_archive_filetype.py, type: likely text
file: tar-zcvf.tar.gz, type: gz

license

project license can be found here

determine-archive-filetype's People

Contributors

joshschmelzle avatar nagayev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.