Generate salt in JavaScript/php.
Hey,
I want to throw out Autoregister, but keep the way the password is encrypted.
Therefore I need to generate a salt on the website, but how do I do that?
I found something like:
PHP Code:
function salt() {
var salt = crypto.randomBytes(16);
return salt;
}
But that doesn't work, so I figured I would ask it here.
Re: Generate salt in JavaScript/php.
I don't know PHP, but I imagine you'd have an array of characters and you could generate random numbers to create a string of some length.
So maybe something like
PHP Code:
function() x {
char[] y = (1, 2, 3, 4, 5, etc.);
String ret = "";
while (ret.length < 12)
ret += y[random]
return ret;
}
Re: Generate salt in JavaScript/php.
Quote:
Originally Posted by
xArmani
I don't know PHP, but I imagine you'd have an array of characters and you could generate random numbers to create a string of some length.
So maybe something like
PHP Code:
function() x {
char[] y = (1, 2, 3, 4, 5, etc.);
String ret = "";
while (ret.length < 12)
ret += y[random]
return ret;
}
I see, I will try it. Thanks!
Re: Generate salt in JavaScript/php.
Isn't Auto-Register a SHA1? o_o
If so, I just ran a test PHP in my www, and this oddly enough worked.
PHP Code:
<?php
$test = "test";
$sha = sha1($test);
echo(" $sha ");
?>
If you were to use this, it calculates the SHA1 format of keyword "test". Not sure if you wanted this or not.
PHP Code:
<?php
$password = 'test';
$hash = crypt($password);
echo (" $hash ");
?>
Another way is to crypt the hash, which can be done like so but isn't detected in your login function in MapleClient, so encrypting this wouldn't work so well plus it changes every time. So yeah, first method is used for Auto Registration and register scripts, also used if someone wants to login to your website but the cms only loads a non-sha1, or a sha1. It can be used to convert to either or.
i'm not le l33t pr0 PHP scripter, so please correct me if i'm wrong.