Created
January 11, 2011 13:44
-
-
Save chmouel/774421 to your computer and use it in GitHub Desktop.
Guess file magic without using python-magic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
__author__ = "Chmouel Boudjnah <[email protected]>" | |
binhexjpg="ffd8ffe000104a464946" | |
import sys | |
import binascii | |
if len(sys.argv) >= 2: | |
ff = sys.argv[1] | |
else: | |
print "Arg needed" | |
sys.exit(1) | |
fh = open(ff, "rb") | |
f = fh.read(10) | |
print binascii.hexlify(f) | |
print binhexjpg | |
print binascii.hexlify(f) == binhexjpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment