filesig
v1.0.4
Published
small library to validate Files by reading each magic number from a file
Downloads
105
Maintainers
Readme
Nodejs File Signature Validator
small library to validate Files by reading each magic number from a file
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);
}
});