0

I want to create a simple form with input fields like old password, new password etc. I want to encrypt the new password (which is a simple text format) the same way as Joomla does. I got the technique, but my problem is I have made a simple PHP page, so what I should import or write in PHP page such that the functions of Joomla like jimport (), JUserHelper() it works.

my code is

jimport('joomla.user.helper');
$salt = JUserHelper::genRandomPassword(32);
echo $salt;

I have tried to do it by simply pasting jimport('joomla.user.helper'), but it was not working .

tshepang
  • 12,111
  • 21
  • 91
  • 136
vishal
  • 1
  • The really does depend on what version of Joomla you're using – Lodder Feb 26 '14 at 11:05
  • check this http://stackoverflow.com/questions/21304038/joomla-3-2-1-password-encryption/21304362#21304362 – Jobin Feb 26 '14 at 11:15
  • @JobinJose - Correct me if I'm wrong, but I believe this method will change a little when they get `bcrypt` running with Joomla again. – Lodder Feb 26 '14 at 12:02

3 Answers3

0

Import User helper and try this:

jimport('joomla.user.helper');
$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword($enteredpassword, $salt);
$passwordtobesaved = $crypt . ':' . $salt;
yprez
  • 14,854
  • 11
  • 55
  • 70
user2064740
  • 44
  • 1
  • 6
0

I had tried below code and it is working fine define('_JEXEC', 1 ); define ('JPATH_BASE', dirname(FILE)); define('DS',DIRECTORY_SEPARATOR); require_once(JPATH_BASE.DS.'includes'.DS.'defines.php'); require_once(JPATH_BASE.DS.'includes'.DS.'framework.php'); require_once(JPATH_BASE.DS.'libraries'.DS.'joomla'.DS.'factory.php'); jimport('joomla.user.helper');

vishal
  • 1
0

Try This:

$new_p = $_POST['posted_password'];
$new_password = JUserHelper::hashPassword($new_p);