Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 963 Bytes

README.md

File metadata and controls

45 lines (35 loc) · 963 Bytes

Nodejs File Signature Validator

small library to validate Files by reading each magic number from a file

filesig Node CI

Requirements

  • Node version 12.x or higher

Install

$ npm install filesig

Usage

Simple

const filesig = require('filesig');
const fs = require('fs');

fs.readFile('/home/john/document.pdf', (err, data) => {
    if (err) {
        console.log(err);
    } else {
        console.log(filesig.isPdf(data));
    }
});

One of

const filesig = require('filesig');
const fs = require('fs');

fs.readFile('/home/john/Capture.PNG', (err, data) => {
    if (err) {
        console.log(err);
    } else {
        let valid = filesig.oneOf(data, filesig.is3gp, filesig.isJpeg, filesig.isPng);
        console.log(valid);
    }
});