Skip to content

telkomdev/node-filesig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
    }
});