You are not logged in.

#1 2014-09-28 19:27:26

mir91
Banned
Registered: 2013-11-17
Posts: 143

[SOLVED] Cmdline tool to create arbitrarily simple checksum?

Is there a command-line tool that can create an arbitrarily simple checksum over random data?
For example I'd like to tell someone a phone number - after he said he received it, I do like

$chksum 3 phone.txt
  A8F

..and get a 3-character length checksum over the contents of phone.txt, by whatever method. The important part is that I can choose a really short checksum if I wanted to, instead of having to memorise an SHA hash or similar.
The idea here is that it must be practical enough to convey verbally to someone. In this regard, it should not distinguish between capital and non-capital letters either.

Last edited by mir91 (2014-09-29 10:14:40)

Offline

#2 2014-09-28 22:57:04

stevenhoneyman
Member
From: England
Registered: 2014-05-25
Posts: 241

Re: [SOLVED] Cmdline tool to create arbitrarily simple checksum?

Just use the first N characters of a sha1 hash - like git does.

Offline

#3 2014-09-28 23:07:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Cmdline tool to create arbitrarily simple checksum?

sha256sum phone.txt | head -c 3

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2014-09-29 00:45:17

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Cmdline tool to create arbitrarily simple checksum?

'head' doesn't print a newline, 'cut' does:

~ $ sha256sum start | head -c 3
32f~ $ sha256sum start | cut -c -3
32f

Offline

#5 2014-09-29 01:01:00

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Cmdline tool to create arbitrarily simple checksum?

Moving to Programming and Scripting...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2014-09-29 10:14:24

mir91
Banned
Registered: 2013-11-17
Posts: 143

Re: [SOLVED] Cmdline tool to create arbitrarily simple checksum?

Thanks, why didn't I think of this!

Offline

Board footer

Powered by FluxBB