Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
4
increased by300%
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc