Generating hash with Argon2 on Botan results in garbage data and 0xC0000005: Access violation reading location 0x0000000100000000

0

I'm trying to hash passwords using the C++ cryptography library Botan. I've tried testing out the library using the code below:

#include <iostream>
#include <string>
#include <botan/argon2.h>
#include <botan/system_rng.h>

int main() {
    Botan::System_RNG rng;
    std::string password = "cool_password";

    std::string generated_hash;
    Botan::argon2_generate_pwhash(password.c_str(), password.length(),
    rng, 1, 4000, 1); // crash occurs here

    std::cout << generated_hash << "\n";
}

but the code either printed garbage data, or gave me a runtime error: Unhandled exception at 0x00007FFEF11825E0 (ucrtbased.dll) in app.exe: 0xC0000005: Access violation reading location 0x0000000100000000.

What should I do? Using other hashing methods such as Botan::generate_bcrypt() also resulted in the same error.

c++
cryptography
botan
argon2-ffi
asked on Stack Overflow Feb 8, 2021 by emredesu • edited Feb 8, 2021 by emredesu

1 Answer

1

After 4 hours of painful troubleshooting and rebuilding the library with different compilers over and over, I have found out that Botan does not work properly if "solution configuration" is not set to "Release" rather than "Debug" in Visual Studio.

answered on Stack Overflow Feb 8, 2021 by emredesu

User contributions licensed under CC BY-SA 3.0