Sponsored Content
Top Forums Shell Programming and Scripting List all files with prepended CRC32 (or other) hash code? Post 302560870 by pstein on Sunday 2nd of October 2011 02:30:04 AM
Old 10-02-2011
List all files with prepended CRC32 (or other) hash code?

I would like to list all files in a directory tree but with a prepended digest hash code (like CRC32). CRC32 is not a MUST. If suitable another hash code can be used as well. In case of CRC32 the listing should look like

Code:
3765AC \usr\bin\spool
23CE99 \usr\bin\spool\list.h
...
11AA04 \etc\apt\sources.list

How can I achieve this?

Peter

Last edited by radoulov; 10-02-2011 at 07:11 AM.. Reason: Code tags!
 

10 More Discussions You Might Find Interesting

1. Programming

crc32 info

hello again, does anyone know where i can find some detailed info about the cyclic redundancy check? thx (2 Replies)
Discussion started by: crashnburn
2 Replies

2. Shell Programming and Scripting

getting data list into a hash array

Begginer alert!! I have just started learning perl and have got stuck. I need to initialize a hash array with values from a list. I've been told to do this using a split command, but its just not happening. Here is the script and output: SCRIPT: #!/bin/perl system("clear"); ... (5 Replies)
Discussion started by: topcat8
5 Replies

3. Shell Programming and Scripting

Print Entire hash list (hash of hashes)

I have a script with dynamic hash of hashes , and I want to print the entire hash (with all other hashes). Itried to do it recursively by checking if the current key is a hash and if yes call the current function again with refference to the sub hash. Most of the printing seems to be OK but in... (1 Reply)
Discussion started by: Alalush
1 Replies

4. UNIX for Advanced & Expert Users

cksum's and zip's CRC32 algorithm

Hello! For long I used cksum to find file duplicates in linux and darwin. Now I want to make my own program that does all. However I can't seem to find the correct algorithm. zip and cksum claim to use the same algorithm, but the computated sums are not the same. I've already written an... (4 Replies)
Discussion started by: regnevakrad
4 Replies

5. Shell Programming and Scripting

Perl Hash:Can not keep hash data in the same order that it was inserted

Can Someone explain me why even using Tie::IxHash I can not get the output data in the same order that it was inserted? See code below. #!/usr/bin/perl use warnings; use Tie::IxHash; use strict; tie (my %programs, "Tie::IxHash"); while (my $line = <DATA>) { chomp $line; my(... (1 Reply)
Discussion started by: jgfcoimbra
1 Replies

6. UNIX for Dummies Questions & Answers

cksum does not give me crc32

Is cksum the right command to calculate the crc32 checksum value? I tried it for a number of files now and every time the results dont match. So there is nothing wrong with the file. Also, cksum gives me an all numerical value while crc32 is alpha numeric. What am I doing wrong? Thanks (9 Replies)
Discussion started by: utamav
9 Replies

7. Shell Programming and Scripting

Perl: Sorting a hash value that is a list.

Hi Folks I am very much a newbie at perl but picking it up and I'm hoping you can help. I have a file input that details all the /etc/group files in our enterprise in the following format: "<host>:<group>:<gid>:<users>" I want to parse this data display it as the following:... (9 Replies)
Discussion started by: g_string
9 Replies

8. Shell Programming and Scripting

Need to simplify code list files in directory

I have the following code that print certain files in my directory and groups things together. I would be good to tidy and simplify this code up and would greatly appreciate suggestions. if ($opt_raytrac == 1) then echo "" echo -n "\033*\)/ & /g' | sort -k 4n | sed 's/ //g' \ # |... (0 Replies)
Discussion started by: kristinu
0 Replies

9. Shell Programming and Scripting

Compare values of hashes of hash for n number of hash in perl without sorting.

Hi, I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all . my %result ( $abc => { 'data_count' => '10', 'ID' => 'ABC122', } $def => { 'data_count' => '20', 'ID' => 'defASe', ... (1 Reply)
Discussion started by: asak
1 Replies

10. Shell Programming and Scripting

Dynamically parse BibTeX and create hash of hash

Hello gurus, Iam trying to parse following BibTex file (bibliography.bib): @book{Lee2000a, abstract = {Abstract goes here}, author = {Lee, Wenke and Stolfo, Salvatore J}, title = {{Data mining approaches for intrusion detection}}, year = {2000} } @article{Forrest1996, abstract =... (0 Replies)
Discussion started by: wakatana
0 Replies
Rhash(3pm)						User Contributed Perl Documentation						Rhash(3pm)

NAME
Rhash - Perl extension for LibRHash Hash library SYNOPSIS
use Rhash; my $msg = "a message text"; print "MD5 = " . Rhash->new(Rhash::MD5)->update($msg)->hash() . " "; # more complex example - calculate two hash functions simultaniously my $r = Rhash->new(Rhash::MD5 | Rhash::SHA1); $r->update("a message text")->update(" another message"); print "MD5 = ". $r->hash(Rhash::MD5) . " "; print "SHA1 = ". $r->hash(Rhash::SHA1) . " "; DESCRIPTION
Rhash module is an object-oriented interface to the LibRHash library, which allows one to simultaniously calculate several hash functions for a file or a text message. SUPPORTED ALGORITHMS
The module supports the following hashing algorithms: CRC32, MD4, MD5, SHA1, SHA256, SHA512, AICH, ED2K, Tiger, DC++ TTH, BitTorrent BTIH, GOST R 34.11-94, RIPEMD-160, HAS-160, EDON-R 256/512, Whirlpool and Snefru-128/256. CONSTRUCTOR
Creates and returns new Rhash object. my $r = Rhash->new($hash_id); my $p = new Rhash($hash_id); # alternative way to call the constructor The $hash_id parameter can be union (via bitwise OR) of any of the following bit-flags: Rhash::CRC32, Rhash::MD4, Rhash::MD5, Rhash::SHA1, Rhash::TIGER, Rhash::TTH, Rhash::BTIH, Rhash::ED2K, Rhash::AICH, Rhash::WHIRLPOOL, Rhash::RIPEMD160, Rhash::GOST, Rhash::GOST_CRYPTOPRO, Rhash::HAS160, Rhash::SNEFRU128, Rhash::SNEFRU256, Rhash::SHA224, Rhash::SHA256, Rhash::SHA384, Rhash::SHA512, Rhash::EDONR256, Rhash::EDONR512 Also the Rhash::ALL bit mask is the union of all listed bit-flags. So the object created via Rhash->new(Rhash::ALL) calculates all supported hash functions for the same data. COMPUTING HASHES
$rhash->update( $msg ) Calculates hashes of the $msg string. The method can be called repeatedly with chunks of the message to be hashed. It returns the $rhash object itself allowing the following construct: $rhash = Rhash->new(Rhash::MD5)->update( $chunk1 )->update( $chunk2 ); $rhash->update_file( $file_path, $start, $size ) $rhash->update_fd( $fd, $start, $size ) Calculate a hash of the file (or its part) specified by $file_path or a file descriptor $fd. The update_fd method doesn't close the $fd, leaving the file position after the hashed block. The optional $start and $size specify the block of the file to hash. No error is reported if the $size is grater than the number of the unread bytes left in the file. Returns the number of characters actually read, 0 at end of file, or undef if there was an error (in the latter case $! is also set). use Rhash; my $r = new Rhash(Rhash::SHA1); open(my $fd, "<", "input.txt") or die "cannot open < input.txt: $!"; while ((my $n = $r->update_fd($fd, undef, 1024) != 0) { print "$n bytes hashed. The SHA1 hash is " . $r->final()->hash() . " "; $r->reset(); } defined($n) or die "read error for input.txt: $!"; close($fd); $rhash->final() Finishes calculation for all data buffered by updating methods and stops hash calculation. The function is called automatically by any of the $rhash->hash*() methods if the final() call was skipped. $rhash->reset() Resets the $rhash object to the initial state. $rhash->hashed_length() Returns the total length of the hashed message. $rhash->hash_id() Returns the hash mask, the $rhash object was constructed with. FORMATING HASH VALUE
Computed hash can be formated as a hexadecimal string (in the forward or reverse byte order), a base32/base64-encoded string or as raw binary data. $rhash->hash( $hash_id ) Returns the hash string in the default format, which can be hexadecimal or base32. Actually the method is equvalent of (Rhash::is_base32($hash_id) ? $rhash->hash_base32($hash_id) : $rhash->hash_hex($hash_id)) If the optional $hash_id parameter is omited or zero, then the method returns the hash for the algorithm contained in $rhash with the lowest identifier. $rhash->hash_hex( $hash_id ) Returns a specified hash in the hexadecimal format. $rhash->hash_rhex( $hash_id ) Returns a hexadecimal string of the hash in reversed bytes order. Some programs prefer to output GOST hash in this format. $rhash->hash_base32( $hash_id ) Returns a specified hash in the base32 format. $rhash->hash_base64( $hash_id ) Returns a specified hash in the base64 format. $rhash->magnet_link( $filename, $hash_mask ) Returns the magnet link containing the computed hashes, filesize, and, optionaly, $filename. The $filename (if specified) is URL- encoded, by converting special characters into the %<hexadecimal-code> form. The optional parameter $hash_mask can limit which hash values to put into the link. STATIC INFORMATION METHODS
Rhash::count() Returns the number of supported hash algorithms Rhash::is_base32($hash_id) Returns nonzero if default output format is Base32 for the hash function specified by $hash_id. Retruns zero if default format is hexadecimal. Rhash::get_digest_size($hash_id) Returns the size in bytes of raw binary hash of the specified hash algorithm. Rhash::get_hash_length($hash_id) Returns the length of a hash string in default output format for the specified hash algorithm. Rhash::get_name($hash_id) Returns the name of the specified hash algorithm. ALTERNATIVE WAY TO COMPUTE HASH
Rhash::msg($hash_id, $message) Computes and returns a single hash (in its default format) of the $message by the selected hash algorithm. use Rhash; print "SHA1( 'abc' ) = " . Rhash::msg(Rhash::SHA1, "abc"); LICENSE
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. The Software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use this program at your own risk! perl v5.14.2 2012-01-09 Rhash(3pm)
All times are GMT -4. The time now is 06:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy