# verify-md5

> Command line client to manage md5 verification of files in local directories and Google Cloud Storage [tm] buckets

Latest version **0.2.1** (published 2018-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install verify-md5
pnpm add verify-md5
yarn add verify-md5
bun add verify-md5
```

Provides the command `verify-md5`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2018-02-17 |
| First published | 2017-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | drpaulbrewer@eaftc.com |
| Maintainers | drpaulbrewer |
| Keywords | md5 |

## Links

- npm: https://www.npmjs.com/package/verify-md5
- Repository: https://github.com/drpaulbrewer/verify-md5
- Homepage: https://github.com/drpaulbrewer/verify-md5#readme
- Issues: https://github.com/drpaulbrewer/verify-md5/issues
- npm.io page: https://npm.io/package/verify-md5

## Dependencies (4)

- [commander](https://npm.io/package/commander.md) ^2.14.1
- [verify-fsdir-md5](https://npm.io/package/verify-fsdir-md5.md) ^0.2.1
- [verify-bucket-md5](https://npm.io/package/verify-bucket-md5.md) ^0.4.0
- [@google-cloud/storage](https://npm.io/package/@google-cloud/storage.md) ^1.6.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.2.1 (latest) — 2018-02-17
- 0.2.0 — 2017-04-04
- 0.1.1 — 2017-04-04
- 0.1.0 — 2017-04-03

## README

# verify-md5

A standalone program to compare a file of md5 hash signatures in `/path/to/md5.json` to the md5 hashes of the contents of the listed files in that same directory

## Installation

To install globally:

    npm i verify-md5 -g

## Prerequisites

1. `nodejs` is installed and accesible by invoking `node`
1. An `md5.json` file consisting of an object with filenames as keys and base64 md5 as value for each key.

Example md5.json file:

<pre>
{
  "data.csv": "fi5F17hHxxqZ9E6gpUlvfA==",
  "profit.csv": "NbLa4M1gKG5Mi1gREVtwWg==",
  "trade.csv": "PTIe1aHM/ww85vzA6UbMAg==",
  "volume.csv": "z8pesXd3MJ7PjmQq+MhNrw==",
  "secretcode.js": "ho5ejYGt7uYwtEZSg8M7QQ==",
  "someotherfile.json": "7Vl0EF+dhruo4YhBFlaW8g=="
}
</pre>


## Usage

If the path begins with `gs://` it refers to a Google Cloud Storage[tm] bucket, e.g. `gs://bucketName/path/to/md5.json`

    verify-md5 --key /path/to/secret/myserviceaccountkey.json gs://bucketName/path/to/md5.json
    
If the path is a filesystem path, the local filesystem is used:

    verify-md5 /path/to/md5.json

`--json` enables json output:

`json` output is a 4 element array:

`[true|false, goodFiles, badFiles, failErrors, dirname]`

Otherwise, "human-readable" output is used.

### Examples

Success example, using storage bucket.

<pre>
verify-md5 --key secret.json gs://somebucket/path/to/md5.json
bucket is somebucket
path is path/to/md5.json
OK gs://somebucket/path/to/md5.json
ok:    effalloc.csv
ok:    ohlc.csv
ok:    profit.csv
ok:    sim.json
ok:    trade.csv
ok:    volume.csv
</pre>

Failure example, with local file system.

<pre>
verify-md5 /tmp/test/md5.json 
FAIL /tmp/test/md5.json
ok:    effalloc.csv
ok:    ohlc.csv
ok:    sim.json
ok:    profit.csv
ok:    trade.csv
fail:  volume.csv md5 File Verification Error on file: /tmp/test/volume.csv : expected: z8pesXd3MJ7PjmQq+MhNrw== actual: 8VMdzVVyB0zpNxwmtJRwUw==
</pre>

<pre>
verify-md5 --json /tmp/test/md5.json 
[
  false,
  [
    "effalloc.csv",
    "ohlc.csv",
    "sim.json",
    "profit.csv",
    "trade.csv"
  ],
  [
    "volume.csv"
  ],
  {
    "volume.csv": {
      "name": "MD5FileVerificationError",
      "message": "md5 File Verification Error on file: /tmp/test/volume.csv : expected: z8pesXd3MJ7PjmQq+MhNrw== actual: 8VMdzVVyB0zpNxwmtJRwUw==",
      "stack": "Error\n    at new MD5FileVerificationError (/usr/local/lib/node_modules/verify-md5/node_modules/verify-fsdir-md5/index.js:17:19)\n    at hasha.fromFile.then (/usr/local/lib/node_modules/verify-md5/node_modules/verify-fsdir-md5/index.js:50:19)\n    at process._tickCallback (internal/process/next_tick.js:103:7)",
      "actual": "8VMdzVVyB0zpNxwmtJRwUw==",
      "expected": "z8pesXd3MJ7PjmQq+MhNrw==",
      "file": "/tmp/test/volume.csv"
    }
  },
  "/tmp/test/"
]
</pre>

## Authentication / Authorization

`verify-md5` on a filesystem path runs with the permissions of the current user.

`verify-md5` on a `gs://` path will attempt to authenticate with the Google Storage API.

Unless you run in the Google Cloud, you will need to include a `--key keyfilename` to access your buckets.

If you need to generate a key for your project, look in the IAM section of the Google Cloud Platform Console and generate  either: 

* a service account key for role: Storage Object Viewer
* or, for granularity, a new service account with no permissions, added as a reader to an individual bucket acl.

Important: It is solely your responsibility to keep API keys secret and manage related security and financial risks.

## Storage API usage

Only the bucket's `md5.json` file is downloaded with a `storage.bucket.file.download` call.  

Then `storage.bucket.file.get` calls are used to access md5 metadata for each file, not `.download()` calls.  

Creating the necessary md5 metadata in the bucket is normally automatic when objects are stored.

Creating the `md5.json` file in the bucket to enable these comparisons is your responsibility.

## Help

    verify-md5 --help

prints this reminder message

<pre>

  Usage: verify-md5 [options] <pathTomd5json>

  Options:

    -h, --help       output usage information
    -V, --version    output the version number
    --key [keyfile]  keyfile to access Google Cloud Storage API
    --json           output test results in json

</pre>


## Copyright

Copyright 2017 Paul Brewer, Economic and Financial Technology Consulting LLC <drpaulbrewer@eaftc.com>

## License

The MIT License

### Trademarks

Google Cloud Storage[tm] is a trademark of Google, Inc.

This software is not a product of Google, Inc.

---
_Source: https://npm.io/package/verify-md5 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
