Sponsored Content
Full Discussion: SHA1 hash calculation
Top Forums Programming SHA1 hash calculation Post 302434221 by ahsaas42 on Thursday 1st of July 2010 11:41:17 PM
Old 07-02-2010
SHA1 hash calculation

hi

i want to generate SHA1 hash of string in Linux (atmark) and downloaded the XYSSL-0.9 version code for the same.i have the algorithm which takes file as argument and returns hash of file . And of same file while I generated the key using online tools then it doesn't match with my compiled library's result.
Do I need to change anything for it while compiling.
Secondly the data is equivalent to while doing memcpy in function rsa_pkcs1_verify(). In this func len is 35 and hasd_id is RSA_SHA1.

is there any conversion required on string before giving to hash generator???
if yes in which form its required??

Thanks,
 

10 More Discussions You Might Find Interesting

1. Programming

MD5 hash calculation

hi i want to generate MD5 hash of string in unix (hp) i have the algorithm which takes file as argument and returns hash of file but when i tried to generate hash of "a" result was "60b725f10c9c85c70d97880dfe8191b3" hash but actually it should have been "0cc175b9c0f1b6a831c399e269772661" now i... (4 Replies)
Discussion started by: zedex
4 Replies

2. 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

3. Shell Programming and Scripting

parse csv file, sha1 hash and output

I have a file, not really a csv, but containing delineated data just the same. Lets call that file "raw_data.txt". It contains data in the format of company name:fein number like this: first company name:123456789 second company name:987654321 what i need to do is read this file, apply... (11 Replies)
Discussion started by: FreddyG
11 Replies

4. 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

5. Shell Programming and Scripting

perl hash - using a range as a hash key.

Hi, In Perl, is it possible to use a range of numbers with '..' as a key in a hash? Something in like: %hash = ( '768..1536' => '1G', '1537..2560' => '2G' ); That is, the range operation is evaluated, and all members of the range are... (3 Replies)
Discussion started by: dsw
3 Replies

6. Shell Programming and Scripting

sha1 question

What is the unix shell scripting equivalent of the following php code? I have tried to reproduce it, but I haven't been able to. <?php sha1(sha1(strtolower($user) . $pass) . $sessionid); ?> (12 Replies)
Discussion started by: locoroco
12 Replies

7. 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

8. 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

9. Shell Programming and Scripting

Need to print hash of hash in table format

Hi, I have a hash of hash where it has name, activities and count i have data like this - $result->{$name}->{$activities} = $value; content of that are - name - robert tom cat peter activities - running, eating, sleeping , drinking, work i need to print output as below ... (3 Replies)
Discussion started by: asak
3 Replies

10. OS X (Apple)

SHA1 verification script

Hi guys! Me again! ... I'm trying to build (on MacOS directly) a bash script that will help me verify a SHA1 digest (to verify downloads and so on and so forth). So first off, here's my version of BASH under OSX: bash-4.4$ And here's my version of Sierra (macOS): 10.12.3 (16D32) ... (2 Replies)
Discussion started by: Ardzii
2 Replies
sha1(n) 						  SHA-x Message-Digest Algorithm						   sha1(n)

__________________________________________________________________________________________________________________________________________________

NAME
sha1 - SHA1 Message-Digest Algorithm SYNOPSIS
package require Tcl 8.2 package require sha1 ?2.0.3? ::sha1::sha1 ?-hex|-bin? [ -channel channel | -file filename | string ] ::sha1::hmac key string ::sha1::hmac ?-hex|-bin? -key key [ -channel channel | -file filename | string ] ::sha1::SHA1Init ::sha1::SHA1Update token data ::sha1::SHA1Final token ::sha1::HMACInit key ::sha1::HMACUpdate token data ::sha1::HMACFinal token _________________________________________________________________ DESCRIPTION
This package provides an implementation in Tcl of the SHA1 message-digest algorithm as specified by FIPS PUB 180-1 (1). This algorithm takes a message and generates a 160-bit digest from the input. The SHA1 algorithm is related to the MD4 algorithm (2) but has been strengthend against certain types of cryptographic attack. SHA1 should be used in preference to MD4 or MD5 in new applications. This package also includes support for creating keyed message-digests using the HMAC algorithm from RFC 2104 (3) with SHA1 as the message- digest. COMMANDS
::sha1::sha1 ?-hex|-bin? [ -channel channel | -file filename | string ] The command takes a message and returns the SHA1 digest of this message as a hexadecimal string. You may request the result as binary data by giving -bin. The data to be hashed can be specified either as a string argument to the sha1 command, or as a filename or a pre-opened channel. If the -filename argument is given then the file is opened, the data read and hashed and the file is closed. If the -channel argument is given then data is read from the channel until the end of file. The channel is not closed. NOTE use of the channel or filename options results in the internal use of vwait. To avoid nested event loops in Tk or tclhttpd applications you should use the incre- mental programming API (see below). Only one of -file, -channel or string should be given. ::sha1::hmac key string ::sha1::hmac ?-hex|-bin? -key key [ -channel channel | -file filename | string ] Calculate an Hashed Message Authentication digest (HMAC) using the SHA1 digest algorithm. HMACs are described in RFC 2104 (3) and provide an SHA1 digest that includes a key. All options other than -key are as for the ::sha1::sha1 command. PROGRAMMING INTERFACE
For the programmer, the SHA1 hash can be viewed as a bucket into which one pours data. When you have finished, you extract a value that is derived from the data that was poured into the bucket. The programming interface to the SHA1 hash operates on a token (equivalent to the bucket). You call SHA1Init to obtain a token and then call SHA1Update as many times as required to add data to the hash. To release any resources and obtain the hash value, you then call SHA1Final. An equivalent set of functions gives you a keyed digest (HMAC). If you have critcl and have built the tcllibc package then the implementation of the hashing function will be performed by compiled code. Failing that if you have the Trf package then this can be used otherwise there is a pure-tcl equivalent. The programming interface remains the same in all cases. ::sha1::SHA1Init Begins a new SHA1 hash. Returns a token ID that must be used for the remaining functions. ::sha1::SHA1Update token data Add data to the hash identified by token. Calling SHA1Update $token "abcd" is equivalent to calling SHA1Update $token "ab" followed by SHA1Update $token "cb". See EXAMPLES. ::sha1::SHA1Final token Returns the hash value and releases any resources held by this token. Once this command completes the token will be invalid. The result is a binary string of 20 bytes representing the 160 bit SHA1 digest value. ::sha1::HMACInit key This is equivalent to the ::sha1::SHA1Init command except that it requires the key that will be included in the HMAC. ::sha1::HMACUpdate token data ::sha1::HMACFinal token These commands are identical to the SHA1 equivalent commands. EXAMPLES
% sha1::sha1 "Tcl does SHA1" 285a6a91c45a9066bf39fcf24425796ef0b2a8bf % sha1::hmac Sekret "Tcl does SHA1" ae6251fa51b95b18cba2be95eb031d07475ff03c % set tok [sha1::SHA1Init] ::sha1::1 % sha1::SHA1Update $tok "Tcl " % sha1::SHA1Update $tok "does " % sha1::SHA1Update $tok "SHA1" % sha1::Hex [sha1::SHA1Final $tok] 285a6a91c45a9066bf39fcf24425796ef0b2a8bf REFERENCES
[1] "Secure Hash Standard", National Institute of Standards and Technology, U.S. Department Of Commerce, April 1995. (http://www.itl.nist.gov/fipspubs/fip180-1.htm) [2] Rivest, R., "The MD4 Message Digest Algorithm", RFC 1320, MIT, April 1992. (http://www.rfc-editor.org/rfc/rfc1320.txt) [3] Krawczyk, H., Bellare, M. and Canetti, R. "HMAC: Keyed-Hashing for Message Authentication", RFC 2104, February 1997. (http://www.rfc-editor.org/rfc/rfc2104.txt) BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category sha1 of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
md4, md5, ripemd128, ripemd160 KEYWORDS
FIPS 180-1, hashing, message-digest, rfc 2104, security, sha1 COPYRIGHT
Copyright (c) 2005, Pat Thoyts <patthoyts@users.sourceforge.net> sha1 2.0.3 sha1(n)
All times are GMT -4. The time now is 11:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy