[LoginController] Create new character.

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
KGB1st
Posts: 230
Joined: Sat Jul 26, 2014 5:58 pm

[LoginController] Create new character.

Post by KGB1st »

In the past I used simple php script for registration my users.
But now I can find new part of code in retriveAccountInfo:

Code: Select all

	MessageDigest md = MessageDigest.getInstance("SHA");
	byte[] raw = password.getBytes(StandardCharsets.UTF_8);
	String hashBase64 = Base64.getEncoder().encodeToString(md.digest(raw));
I read about these functions in google and guess some about how l2j create accounts. But... When I count bytes(summ bytes each of arrays' elements) of string(password) and then encode this value into SHA, then in Base64, I can't get correct result.

Example:

Code: Select all

		$byte;
		$bytes = array();
		for($i = 0; $i < strlen($pwd); $i++){
			$bytes[] = ord($pwd[$i]);
			$byte += ord($pwd[$i]);
		}
		print_r($bytes);

Code: Select all

const char[] password = Base64(SHA($byte)); // This's example, not php method
but password string from php not equals same password string in db (really password is equals)

P.S. find method how I can do it. But I dont fully understand how it works in J. :?

Code: Select all

var_dump( base64_encode( pack( 'H*', sha1( $pwd ) ) ) ); // PHP
Post Reply