Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Photogram project PHP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raghav
Photogram project PHP
Commits
9ca2d44a
You need to sign in or sign up before continuing.
Commit
9ca2d44a
authored
2 weeks ago
by
Raghav
Browse files
Options
Downloads
Patches
Plain Diff
Verified User password with simple way: Success
parent
1cab2e0d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
_includes/User.class.php
+29
-11
29 additions, 11 deletions
_includes/User.class.php
logintest.php
+13
-0
13 additions, 0 deletions
logintest.php
testhash.php
+12
-0
12 additions, 0 deletions
testhash.php
with
54 additions
and
11 deletions
_includes/User.class.php
+
29
−
11
View file @
9ca2d44a
...
@@ -9,7 +9,7 @@ class User
...
@@ -9,7 +9,7 @@ class User
$conn
=
Database
::
getConnection
();
$conn
=
Database
::
getConnection
();
// To save password as md5 hash format
// To save password as md5 hash format
$pass
=
md5
(
$pass
);
$pass
=
md5
(
strrev
(
md5
(
$pass
)));
//Security through obscurity
$sql
=
"INSERT INTO `auth` (`username`, `password`, `email`, `phone`, `block`, `active`)
$sql
=
"INSERT INTO `auth` (`username`, `password`, `email`, `phone`, `block`, `active`)
VALUES ('
$user
', '
$pass
', '
$email
', '
$phone
', '0', '1');"
;
VALUES ('
$user
', '
$pass
', '
$email
', '
$phone
', '0', '1');"
;
...
@@ -27,20 +27,38 @@ class User
...
@@ -27,20 +27,38 @@ class User
return
$error
;
return
$error
;
}
}
public
static
function
getCredential
(
$email
,
$pass
)
// Check whether the user credential is exists in database
{
public
static
function
login
(
$user
,
$pass
){
// Since it is in static function we need to declare again in this function.
$password
=
$pass
;
// Connect to Database
// store query in a variable
$query
=
"SELECT * FROM `auth` WHERE `username` = '
$user
'"
;
// To get database connection
$conn
=
Database
::
getConnection
();
$conn
=
Database
::
getConnection
();
Database
::
getUserData
(
$email
,
$pass
);
// sends the query with query() to get the data from database
$result
=
$conn
->
query
(
$query
);
}
/*
[*] Accessing (num_rows) is the variable present inside the class eg: $object->variable_name;
*/
if
(
$result
->
num_rows
==
1
){
// fetch data as array from database and store in $row
$row
=
$result
->
fetch_assoc
();
// validate password from database
if
(
$row
[
'password'
]
==
$password
){
return
$row
;
}
else
{
return
false
;
}
}
else
{
return
false
;
}
public
static
function
setCredential
()
{
Database
::
setUserData
();
}
}
}
}
This diff is collapsed.
Click to expand it.
logintest.php
0 → 100644
+
13
−
0
View file @
9ca2d44a
<?php
include
'libs/load.php'
;
$user
=
"devyani "
;
$pass
=
"devyani"
;
$result
=
User
::
login
(
$user
,
$pass
);
if
(
$result
)
{
echo
"Login success"
;
}
else
{
echo
"Login failed"
;
}
This diff is collapsed.
Click to expand it.
testhash.php
0 → 100644
+
12
−
0
View file @
9ca2d44a
<?php
$str
=
<<<"raghav"
[*] Hello I am raghav fro selfmade ninja
[*] here we are going to see about hashing [md5] how md5() works
[*] Is it stores the whole data into 32bit data?
[*} Hey buddy what's up????
raghav;
echo
"string length: "
.
strlen
(
$str
)
.
"
\n
"
;
echo
"md5: "
.
md5
(
$str
)
.
"(length: "
.
strlen
(
md5
(
$str
))
.
")
\n
"
;
echo
"base64: "
.
base64_encode
(
$str
)
.
"
\n
(Length: "
.
strlen
(
base64_encode
(
$str
))
.
")"
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment