Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help simplifying this to hash lines of text file #2

Closed
merclyn opened this issue Feb 13, 2018 · 5 comments
Closed

Need help simplifying this to hash lines of text file #2

merclyn opened this issue Feb 13, 2018 · 5 comments

Comments

@merclyn
Copy link

merclyn commented Feb 13, 2018

I was trying to use your code as a starting point to make a sha256 cuda hasher that takes lines from stdin (Or any text file) and hashes each line as a job (Outputing HASH and Original Line in the output separated by a space or other delimiter)

Your program is so close to doing this (You hash filesystem files), but my c++ is weak. Can you assist me? The way you read the files in for the –f switch, but instead of getting the file data from get_file_data, could you just hash the string?

@Horkyze
Copy link
Owner

Horkyze commented Feb 14, 2018

Hi, of course you can!

Notice this line:

jobs[i] = JOB_init(buff, temp, argv[index]);

buff stands for buffer and it's nothing else then a string. So you can pass in whatever you want.
If you dont know how to read input from stdin, I suggest you google that, there are a lot of good tutorials out there.

@merclyn
Copy link
Author

merclyn commented Feb 14, 2018

I thought I tried that earlier, ill try it again.
In your code, if I passed in the variable line in place of buff, should I replace temp with strlen(line)? this is what I thought I did. Once I have it working with a string, I can easily get stdin working. Ill give it a shot later in the day.

Again, Thanks for the help.

@merclyn
Copy link
Author

merclyn commented Feb 14, 2018

Im real close, but still cigar.

I added these 3 lines directly above the line 194 you refer to above:
buff = (BYTE *)"Hello";
checkCudaErrors(cudaMallocManaged(&buff, (5)*sizeof(char)));
jobs[i] = JOB_init(buff, 5, argv[index]);
and I get this hash:
8855508aade16ec573d21e6a485dfd0a7624085c1a14b5ecdd6485de0c6839a4 file.1
but I believe the hash is incorrect, because I compare it to:
$ echo -n "Hello" | sha256sum
and I get:
185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969 -

I would expect the hash from both of those to match exactly.

BTW: If I dont cast buff to (BYTE *) then I get a compile error. Once I have this working with a simple string, ill be able to take it from there.

@merclyn
Copy link
Author

merclyn commented Feb 14, 2018

I have some progress. I seem to need to better understand variable pointers in c++.

@Horkyze Horkyze closed this as completed Jan 10, 2020
@Fyzjym
Copy link

Fyzjym commented May 30, 2021

Hello, may I ask for your help?

After I modify the code, I get an incorrect hash value.

			buff = (BYTE *)"abc";
			checkCudaErrors(cudaMallocManaged(&buff, (3)*sizeof(char)));
			jobs[i] = JOB_init(buff, 3, argv[index]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants