GithubHelp home page GithubHelp logo

rattleycooper / fsigs Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 25 KB

Library for validating files based on their file signature. 175+ file signatures included.

License: MIT License

Nim 100.00%
file-signatures validation

fsigs's Introduction

fsigs

fsigs is a nim library made for validating files based on their file signature. fsigs can check against multiple file signatures very quickly(175+ file signatures in less than 1ms). File signatures were taken from this list, however I did not implement them all. If a file signature is missing, create a pull request or open an issue explaining which file signature you'd like added. If it's not on the list from wikipedia then provide as much detail about how you obtained the file signature.

Signatures

Signature names are listed in the signatures.nim file. It's important to note that some file types contain multiple file signatures, so you have to check against all signatures for that file type.

Installation

nimble install https://github.com/RattleyCooper/fsigs

Example

# Procs in `fsigs`
# FileSignatures in `signatures`
import fsigs/[fsigs, signatures]

const testSig1 = "\x52\x49\x46\x46\x01\x02\x03\x04\x57\x41\x56\x45"
echo testSig1.matches(SigWav)

const fileSigs = @[
  SigJpeg0,
  SigJpeg1,
  SigJpeg2,
  SigJpeg3
] 

var f: File
if not f.open("some.jpg", fmRead):
  raise newException(OSError, "File could not be opened.")

for fileSig in fileSigs:
  if f.matchesAny(fileSig):
    echo fileSig.id

let sig = f.signature(fileSigs)
echo sig
echo sig == fSigJpeg1
echo f.signature(AllFileSignatures)
echo f.matchesAny(fileSigs)

f.close()

fsigs's People

Contributors

rattleycooper avatar

Stargazers

 avatar  avatar  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.