hashpipe

hashpipe - 如果哈希值匹配,则进行管道处理。「hashpipe - pipe iff the hash matches」

Github stars Tracking Chart

hashpipe - pipe iff the hash matches

hashpipe helps you venture into the unknown. It reads from stdin, checks the hash of the content, and outputs it IF AND ONLY IF it matches the provided hash checksum. This makes executing things a teensy bit safer, as it requires compromising more communication channels.

Example

> echo "hello" | multihash
QmUJPTFZnR2CPGAzmfdYPghgrFtYFB6pf1BqMvqfiPDam8
> echo "hello" | hashpipe QmUJPTFZnR2CPGAzmfdYPghgrFtYFB6pf1BqMvqfiPDam8
hello
> echo "goodbye" | hashpipe QmUJPTFZnR2CPGAzmfdYPghgrFtYFB6pf1BqMvqfiPDam8
error: multihash checksums did not match

Use Case

If you tell people to pipe things directly into the shell... Don't do that. If you're going to, at least provide them a hash to ensure that man-in-the-middle attacks or compromised CDNs do not hurt your users.

curl http://you.shouldnt.be/doing/this | hashpipe Qmepk1VCHpjyCmWeh61vyDKsWfKymyrBQLcmUpXUdUd3yM | sh

Hashes Supported

hashpipe uses multihash, a self-describing hash function. It supports all the hashes in go-multihash:

Install

Usage

> hashpipe -h
usage: hashpipe [MULTIHASH] <[FILE] >[FILE]

    cat untrustedFile | hashpipe <expected-checksum> | trustedContext

hashpipe - boldly journey into the unknown.

It reads from stdin, checks the hash of the content, and outputs it IF AND
ONLY IF it matches the provided hash checksum. This makes executing things
a bit safer, as it requires compromising more communication channels. On
error, hashpipe returns a non-zero error code, failing pipelines.

OPTIONS
  -a="sha2-256": one of: sha1, sha2-256, sha2-512, sha3 (shorthand)
  -algorithm="sha2-256": one of: sha1, sha2-256, sha2-512, sha3
  -e="base58": one of: raw, hex, base58, base64 (shorthand)
  -encoding="base58": one of: raw, hex, base58, base64
  -l=-1: checksums length in bits (truncate). -1 is default (shorthand)
  -length=-1: checksums length in bits (truncate). -1 is default
  -q=false: quiet output (no newline on checksum, no error text) (shorthand)
  -quiet=false: quiet output (no newline on checksum, no error text)

Main metrics

Overview
Name With Ownerjbenet/hashpipe
Primary LanguageGo
Program languageGo (Language Count: 2)
Platform
License:MIT License
所有者活动
Created At2015-04-03 09:51:05
Pushed At2022-01-06 07:17:35
Last Commit At2015-04-05 03:18:20
Release Count0
用户参与
Stargazers Count406
Watchers Count19
Fork Count16
Commits Count9
Has Issues Enabled
Issues Count5
Issue Open Count3
Pull Requests Count1
Pull Requests Open Count0
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private