Encrypting a password the same in C# and PHP?

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.

Re: Encrypting a password the same in C# and PHP?

Postby KyleMassacre » Tue Jul 10, 2018 1:43 pm

An example use case would be something like this, Ican’t do the C# part of it but in the PHP side of things:
Code: Select all
// Return the JWT if the user successfully logs in
$username = filter_input(INPUT_POST,'username',FILTER_SANITIZE_STRING);
$pass = filter_input(INPUT_POST,'password',FILTER_SANTIZE_STRING);
$user = $db->query('select * from users where username='.$username.', password='.$password);
$key = "example_key";
$token = array(
    "sub" => $user->id,
    "iss" => "http://example.org",
    "aud" => "http://example.com",
    "iat" => 1356999524,
    "nbf" => 1357000000
);
$jwt = JWT::encode($token,$key);
return json_encode(['jwt' => $jwt]);

// Parse the token to get the user
$jwt = filter_input(INPUT_POST,'token',FILTER_SANTIZE_STRING);
$decoded = JWT::decode($jwt, $key, ['HS256']);
$user = $db->query('select * from users where id='.$decoded->sub);

UPDATE: Looks like you would use PlayerPrefs to possibly save the JWT on the app environment
Skype: KyleMassacre
My NWE Modules
User avatar
KyleMassacre
 
Posts: 567
Joined: Wed Nov 27, 2013 7:42 am
Has thanked: 19 times
Been thanked: 36 times

Re: Encrypting a password the same in C# and PHP?

Postby KyleMassacre » Sat Jul 14, 2018 10:34 am

Don’t want to bug but did you get it figured out OldRod?
Skype: KyleMassacre
My NWE Modules
User avatar
KyleMassacre
 
Posts: 567
Joined: Wed Nov 27, 2013 7:42 am
Has thanked: 19 times
Been thanked: 36 times

Re: Encrypting a password the same in C# and PHP?

Postby OldRod » Wed Jul 18, 2018 8:55 am

Haven't had time to look at it - July is my busiest time at work... will be a bit before I can get back to that problem

Thanks for the help though :)
User avatar
OldRod
 
Posts: 1320
Joined: Sun Sep 20, 2009 11:26 am
Location: Kansas
Has thanked: 2 times
Been thanked: 9 times

Previous

Return to Advanced Help and Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x