-2

I'm developing some experimental program that requires hashing strings.

I tried all the source code I could find on the internet but none of it seemed to work without any dependencies, can you please link the source to a cryptographic hashing function that has no dependencies, i.e. something that I can just copy/paste into my code and it would work?

PS I prefer a secure hashing function, but MD5 would be fine for now.

halfer
  • 19,824
  • 17
  • 99
  • 186
Tom
  • 105
  • 1
  • 1
  • 6
  • If you don't need cryptographically secure hashing algorithm, why not use a simple string hashing algorithm then? – PythEch Dec 09 '17 at 21:11
  • I'm experimenting with an encryption algorithm that requires hashing a key to make it secure – Tom Dec 09 '17 at 22:05
  • Please, define the exact meaning of _any cryptographic hashing function that has NO DEPENDENCIES_. Dependencies on what? Why do you need your hash to be cryptographic? are you going to protect something with the hash value? This is not a place to get things just to _copy and paste_, but to learn programming. Don't come with those requirements, you are not going to get help that way. – Luis Colorado Dec 11 '17 at 08:51

1 Answers1

1

You may want to check Simple MD5 implementation with no dependences.

Also check these proposals: hash function for string.

It is worth to mention that there are other open source implementations like:

Basic implementations of standard cryptography algorithms, like AES and SHA-1 and sphlib an open source library which provides optimized and portable implementations of many hash functions.

sg7
  • 6,108
  • 2
  • 32
  • 40
  • i'm sorry, but the implementation that you provided does not compile and i'm not sure why, thank you anyway – Tom Dec 09 '17 at 21:30
  • For a simple, non-crypto hashing function try the [FNV](http://isthe.com/chongo/tech/comp/fnv/) hash. – rossum Dec 09 '17 at 21:39
  • @Tom It does compile for me. I use GCC 5.3.0 compiler. – sg7 Dec 09 '17 at 22:01
  • @sg7 yes it was something trivial for me, thank you very much!! – Tom Dec 09 '17 at 22:02
  • These are not cryptographically secure. – PythEch Dec 09 '17 at 22:06
  • @PythEch Correct! OP indicated that MD5 _would be fine for now_. – sg7 Dec 09 '17 at 22:10
  • 1
    @Tom, what do you mean with _does not compile_? have you executed the compiler by hand? have you some knowledge about how to compile a source file? most important: Did you get any error message from the compiler? is it possible to see what error did you get? Do you want this question proposed to be closed? Have you read the tutorial on _how to ask_ in StackOverflow? – Luis Colorado Dec 11 '17 at 08:54