CudaSHA256 icon indicating copy to clipboard operation
CudaSHA256 copied to clipboard

incorrect hashes

Open 69b69t opened this issue 1 year ago • 2 comments

Hashing "hello world!" should return 7509e5bda0c762d2bac7f90d758b5b2263fa01ccbc542ab5e3df163be08e6ca9, and hashing that in a file works, when i try to use the api to hash "hello world!", it gives a totally incorrect hash.

(code that produces incorrect result)

#include <stdio.h>
#include <stdint.h>
#include "sha256.cuh"


__global__ void seedHash()
{
    uint8_t testInput[] = "hello world!";

    //memcpy(byteArray, &seed, sizeof(uint64_t));

    uint8_t byteArray[32];
    SHA256_CTX sha;
    sha256_init(&sha);
    sha256_update(&sha, testInput, 12);
    sha256_final(&sha, byteArray);

    printf("Hash output: ");
    for (int i = 0; i < 32; i++) printf("%.2x", byteArray[i]);
    printf("\n");
}

int main()
{
    //cudaSetDevice(1);
    seedHash<<<1,1>>>();
    cudaDeviceSynchronize();
}

69b69t avatar Dec 22 '23 21:12 69b69t