notiuni neintelese

15 views
Skip to first unread message

andrei

unread,
Nov 28, 2013, 4:20:26 AM11/28/13
to Linux User Group Braşov
exemplu:
 ce înseamnă ?


using sha1 encryption

060201080808040602040909080909003583150369840500 = D8F6B336A4DF3336BF7DE58A38B1189F6C5CE1E8

try it in hexcalc using hex string data format and see that the 48 hex char string on the left generates the above 40 char hash

_______________________________________
adică
 echo -n "andrei"| sha1sum
calculează hashul pt sirul de caractere "andrei" dar în exemplul de mai sus ?


===footer===
Andrei Florescu
GPG keyID 0x3C075830 (9728 B252 E527 869B F0EA  0301 D95F CCEF 3C07 5830)
gpg --keyserver pgp.mit.edu --recv-keys 0x3C075830
Don't use the same RSA key for encryption and signing!
===retoof===

Doru Ilasi

unread,
Nov 28, 2013, 5:01:15 AM11/28/13
to lista LUG Brasov
Salut Andrei,


On Thu, Nov 28, 2013 at 11:20 AM, andrei <fandr...@yahoo.com> wrote:
exemplu:
 ce înseamnă ?


using sha1 encryption

060201080808040602040909080909003583150369840500 = D8F6B336A4DF3336BF7DE58A38B1189F6C5CE1E8

try it in hexcalc using hex string data format and see that the 48 hex char string on the left generates the above 40 char hash


_______________________________________
adică
 echo -n "andrei"| sha1sum
calculează hashul pt sirul de caractere "andrei" dar în exemplul de mai sus ?

da


===footer===
Andrei Florescu
GPG keyID 0x3C075830 (9728 B252 E527 869B F0EA  0301 D95F CCEF 3C07 5830)
gpg --keyserver pgp.mit.edu --recv-keys 0x3C075830
Don't use the same RSA key for encryption and signing!
===retoof===

--
--
You received this message because you are subscribed to the Google Groups "lugbv" group.
To post to this group, send email to lu...@googlegroups.com
To unsubscribe from this group, send email to lugbv-un...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/lugbv?hl=ro
 
For anything else, visit http://www.osn.ro/
---
Aţi primit acest mesaj deoarece sunteţi abonat(ă) la grupul „LUG Braşov” din Grupuri Google.
 
Pentru a vă dezabona de la grup şi pentru a nu mai primi e-mailuri de la acesta, trimiteţi un e-mail la adresa lugbv+un...@googlegroups.com.
Pentru mai multe opţiuni, accesaţi https://groups.google.com/groups/opt_out.

andrei

unread,
Nov 28, 2013, 5:55:23 AM11/28/13
to lu...@googlegroups.com
problema este ceva de genul
http://stackoverflow.com/questions/15669550/get-sha1-of-hexstring-like-hashcalc-does

dar nu înțelg ce fac

transformă "hex stringul" in array de byts si apoi calculeaza sha1 ?


 



===footer===
Andrei Florescu
GPG keyID 0x3C075830 (9728 B252 E527 869B F0EA  0301 D95F CCEF 3C07 5830)
gpg --keyserver pgp.mit.edu --recv-keys 0x3C075830
Don't use the same RSA key for encryption and signing!
===retoof===


From: Doru Ilasi <doru...@gmail.com>
To: lista LUG Brasov <lu...@googlegroups.com>
Sent: Thursday, November 28, 2013 12:01 PM
Subject: Re: [LUGBV & osn.ro: 339] notiuni neintelese

andrei

unread,
Dec 4, 2013, 3:08:47 AM12/4/13
to lu...@googlegroups.com
Nu știam ce este acela un hex string"".
Acuma am înțeles. (cred că pentru majoritatea este ceva banal, dar nu a fost și pt mine).

citez:

"
I think for the most part you are just doing unnecessary calculations and using unnecessary temporary space.

One of the reasons hexadecimal is so nice is because 1 hexa digit is equal to a nibble or 4 bits, so if I were supposed to convert your string into a byte string it would have to be like:
Code:
A4	 50 	 5D 	  0B 	   0F 	    6A	     ED	      AA
10100100 0101000 01011101 00001011 00001111 01101010 11101101 10101010
Each column is one byte of string. BTW this is for illustration. Just don't mind the numbers too much, I tried to convert to binary and I think it's right, but I might have transposed some digits or something.

The good news is that sscanf can indeed do this work, but you need to handle it two characters at a time, because it is the same as storing the result one byte at a time.

Additionally, if you actually look up the %X conversion for sscanf (check your syntax!) you will find that the result is expected to be a unsigned int. Just use a temporary variable with sscanf, and cast over to unsigned char or char, whichever is right, when you put it into the byte string. I am fairly sure this was completely ignored in your attempt and contributed to things being very wrong."

#include <stdio.h>
 
int main() {
    int i, n;
    char *HEXStr = "A4505D0B0F6AEDAA";
    unsigned char tmpByte[9];
    char backHex[17];
 
    for(i = 0; i < 16; i++) {
        sscanf(HEXStr+2*i, "%2X", &n);
        tmpByte[i] = (char)n;
    }
 
    for(i = 0; i < 8; i++)
        sprintf(backHex+2*i, "%02X", tmpByte[i]);
    backHex[16] = '\0';
 
    printf("%s\n", backHex);
    return 0;
}


Am citat din linkul de mai jos.

http://cboard.cprogramming.com/c-programming/150170-how-change-hex-string-byte-array.html

 



===footer===
Andrei Florescu
GPG keyID 0x3C075830 (9728 B252 E527 869B F0EA  0301 D95F CCEF 3C07 5830)
gpg --keyserver pgp.mit.edu --recv-keys 0x3C075830
Don't use the same RSA key for encryption and signing!
===retoof===


From: andrei <fandr...@yahoo.com>
To: "lu...@googlegroups.com" <lu...@googlegroups.com>
Sent: Thursday, November 28, 2013 12:55 PM
Subject: Re: [LUGBV & osn.ro: 340] notiuni neintelese
Reply all
Reply to author
Forward
0 new messages