0

For Generating SHA1 key in C, I can use :

// The data to be hashed
char data[] = "Hello, world!";
size_t length = sizeof(data);

unsigned char hash[SHA_DIGEST_LENGTH];
SHA1(data, length, hash);
// hash now contains the 20-byte SHA-1 hash 

As described here : https://stackoverflow.com/a/9284520/3019006

I want to generate the same key in Java, so that the two keys match if same data is fed. What should I use?

Deb
  • 5,163
  • 7
  • 30
  • 45
  • Have you tried to google "sha1 Java"? – NickL Mar 27 '18 at 19:00
  • Yes. And for java, there are different ways of doing it. Thats why I doubt whether the key will match with the key generated in C. Because it accepts prameter like length. – Deb Mar 27 '18 at 21:50

0 Answers0