SHA1 hash calculation


 
Thread Tools Search this Thread
Top Forums Programming SHA1 hash calculation
# 1  
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,
# 2  
Old 07-02-2010
Please show us your code. It is difficult to assist you without seeing what you are doing.
# 3  
Old 07-02-2010
Can u please let me know the hashkey generated via sha1sum unix command will it be similar to the one generated by sha1 of xyssl library.
If not why there will be a difference.
# 4  
Old 07-03-2010
In theory they should be the same. However,we cannot really help you unless you show us your code.
# 5  
Old 07-03-2010
Hi.

I installed libxyssl-dev and it populated a directory with a number of examples. The one I found useful for this thread is a c code, uploaded (below) as a txt file. It is from:
Code:
/usr/share/doc/libxyssl-dev/examples/hash/sha1sum.c

on a GNU/Debian system:
Code:
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0

I wote a quick perl code and compared a few other methods to calculate the sha1 hash. The results are:
Code:
Whole: 15:0:15 of 4 lines in file "data1"
Now is the time
for all good men
to come to the aid
of their country.
 || end

-----
 Results, perl:
7de790fbe559d66cf890671ea2ef706281a1017f  data1 (perl)

-----
 Results, sha1sum:
7de790fbe559d66cf890671ea2ef706281a1017f  data1

-----
 Results, openssl OpenSSL 0.9.8g 19 Oct 2007:
SHA1(data1)= 7de790fbe559d66cf890671ea2ef706281a1017f

-----
 Results, sample c code ( 156 lines ):
-rwxr-xr-x 1 26335 Jul  3 13:14 a.out
7de790fbe559d66cf890671ea2ef706281a1017f  data1 (c code)

Your install will probably have placed relevant files in places different from those for my install.

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
Login or Register to Ask a Question