mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-07-08 11:00:08 +00:00

* Merge kamilprzyb and main repo's code * Update Makefile by FunnHornhoover * Update Makefile by FinnHornhoover * Add flag to Makefile by FinnHornhoover * Remove extra line from makefile * Remove lbcrypt from Makefile * Fix flag to Makefile by FinnHornhoover * Reimplement potential fix for tutorial blackscreen by Dongresources * Update CMakeLists.txt * Update CMakeLists.txt * Reinsert Jade's changes * Cosmetic Changes to Databases .h & .cpp * Remove CMakeSettings.json * Update Makefile by Finn Hornhoover * More cosmetic changes to Databases.cpp * More cosmetic changes to Databases.cpp * Remove unnecessary line (CMakeSettings.json) * Fix CNLoginServer.cpp * More cosmetic Changes to Database.hpp, edit Database.cpp to use JSON library onstead of json11 library, and delete json11 library files * Delete json11 library files * Delete JSON library to reupload * Reupload JSON library from main repo * Reupload JSON library from main repo * Fix syntax error * Fix Makefile * Remove commented line of code to be like master Co-authored-by: CPunch <sethtstubbs@gmail.com>
27 lines
741 B
C++
27 lines
741 B
C++
#ifndef __WIN_BCRYPT__H
|
|
#define __WIN_BCRYPT__H
|
|
|
|
#include <iostream>
|
|
|
|
#include "crypt_blowfish.h"
|
|
#include "bcrypt.h"
|
|
|
|
class BCrypt {
|
|
public:
|
|
static std::string generateHash(const std::string & password, int workload = 12) {
|
|
char salt[BCRYPT_HASHSIZE];
|
|
char hash[BCRYPT_HASHSIZE];
|
|
int ret;
|
|
ret = bcrypt_gensalt(workload, salt);
|
|
if (ret != 0)throw std::runtime_error{ "bcrypt: can not generate salt" };
|
|
ret = bcrypt_hashpw(password.c_str(), salt, hash);
|
|
if (ret != 0)throw std::runtime_error{ "bcrypt: can not generate hash" };
|
|
return std::string{ hash };
|
|
}
|
|
|
|
static bool validatePassword(const std::string & password, const std::string & hash) {
|
|
return (bcrypt_checkpw(password.c_str(), hash.c_str()) == 0);
|
|
}
|
|
};
|
|
|
|
#endif |