🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

check-header-hex

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-header-hex

Checks read stream of files for proper hex headers, the function is a generator

2.0.0
latest
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

check-header-hex

This repository checks for valid file headers; the function is a generator, so you need to yield.

##Usage

npm install check-header-hex

'use strict';

let fs       = require('fs');
let co       = require('co');
let check    = require('check-header-hex');

const VALID_HEX = '25504446,FFD8FFE1, FFD8FFE0, FFD8FFFE, 89504E47';

let start = function () {
  co( function *() {
    let streamJPG        = fs.createReadStream('./example.jpg');
    let isValid          = yield check.checkIfValidHeader(VALID_HEX, streamJPG);

    let streamTXT        = fs.createReadStream('./bad.txt');
    let shouldNotBeValed = yield check.checkIfValidHeader(VALID_HEX, streamTXT);

    console.log('example.jpg:', isValid);
    console.log('bad.txt:', shouldNotBeValed);

  }).catch(function (err) {
    console.error(err);
  });

};

start();

The function returns true or false.

Keywords

read

FAQs

Package last updated on 06 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts