Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
password hashing working
  • Loading branch information
“craciun2” committed Mar 2, 2018
1 parent bae452a commit a75b9980497e5598fe408bad7b8bc1a573a9fcee
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 18 deletions.
BIN -4.05 KB (91%) MAIN
Binary file not shown.
@@ -9,10 +9,31 @@
using namespace std;
#include "libsqlite.hpp"
#include "InGameMenu.cpp"
#include "md5.h"



string hashPassword(string password)
{
string ecryptedPassword;
ecryptedPassword = md5(password) ;

return ecryptedPassword;
}

int createTeam(int Player_ID, string teamName)
{


sqlite::sqlite db( "ball.sqlite" );
auto cur = db.get_statement();
cur->set_sql( "INSERT INTO MyTeam (Player_ID, TeamName) VALUES (?,?);" );
cur->prepare();
cur->bind( 1, Player_ID );
cur->bind( 2, teamName );
cur->step();
return 0;
}



@@ -21,6 +42,7 @@ char menuu()
{
char choice;

hashPassword("ola");
MainMenu:
do
{
@@ -42,15 +64,17 @@ char menuu()
{
case '1':
{
string username, password;
string username, password, ecryptedPassword;
bool Blog = false;
// login part
logs:
logs:
cout << "*******************************\n";
cout << "ID: ";
cin >> username ;
cout << "Password: ";
cin >> password ;
cout << "Checking Data..." << endl ;
ecryptedPassword = hashPassword(password);

// cheking on the data base
try
@@ -62,15 +86,16 @@ char menuu()
cur->prepare();

cur->bind( 1, username );
cur->bind( 2, password );
cur->bind( 2, ecryptedPassword );
int result= cur->step();
int Player_ID = cur->get_int(0); // to get the playerID (unique identification on DB)
if (result == true){
cout<<"login Sucessful"<<endl;
MenuGame(Player_ID);
}
else{
cout<<"Username of password are wrong"<<endl;
cout<<"Username of password are wrong"<<endl << "Try Again" << endl;
goto logs;
} //end else case


@@ -86,7 +111,7 @@ char menuu()
}
case '2':
{
string username, email, password, veriyPassword, teamName;
string username, email, password, veriyPassword, teamName, ecryptedPassword;

regist:
// login part
@@ -107,6 +132,8 @@ char menuu()
cout << "Processing Data" << endl ;
cout << ""<< endl;



//check if already with same user name
try
{
@@ -126,14 +153,15 @@ char menuu()
}//end of if case
else
{
ecryptedPassword = hashPassword(password); // ecrypting the password
//registin part
cur = db.get_statement();
cur->set_sql( "INSERT INTO Player (UserName, Email,Password) "
"VALUES (?, ?,?);" );
cur->prepare();
cur->bind( 1, username );
cur->bind( 2, email );
cur->bind( 3, password );
cur->bind( 3, ecryptedPassword );
cur->step();
cout<<"Registed Sucessful"<<endl;
cout<<endl<<endl;
@@ -149,17 +177,9 @@ char menuu()
int Player_ID = cur->get_int(0);
//sqlite::sqlite3_close(db);
cur = NULL;
//createTeam(Player_ID,teamName); // caling to create a team
createTeam(Player_ID,teamName); // create the team for the player (inserting in dabase)
// end of getting the ID
// Create the team
cur = db.get_statement();
cur->set_sql( "INSERT INTO MyTeam (Player_ID, TeamName) VALUES (?,?);" );
cur->prepare();
cur->bind( 1, Player_ID );
cur->bind( 2, teamName );
cur->step();



goto MainMenu;
}//end of else
}// end of try block
@@ -30,12 +30,13 @@ g++ --std=c++14 Main.cpp -o MAIN -lsqlite3

g++ --std=c++14 hastest.cpp -o HAS -lsqlite3

g++ --std=c++14 Main.cpp md5.cpp -o HAS -lsqlite3 md5_sample && ./md5_sample
g++ --std=c++14 Main.cpp md5.cpp -o HAS -lsqlite3 -o md5_sample && ./md5_sample

g++ pass.cpp md5.cpp -o md5_sample && ./md5_sample


g++ --std=c++14 MenuRascunho.cpp -o RASCUNHO -lsqlite3
g++ ncurses.cpp -lncurses




BIN +8.88 KB a.out
Binary file not shown.
BIN +0 Bytes (100%) ball.sqlite
Binary file not shown.
BIN +30.5 KB (260%) md5_sample
Binary file not shown.
@@ -0,0 +1,22 @@
#include <curses.h>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <stdexcept>
#include <stdio.h>
#include <string.h>
using namespace std;


int main ()
{

initscr();
mvprintw(10,15, "Hello world");
refresh();
getch();
endwin();

return 0;
}

0 comments on commit a75b998

Please sign in to comment.