⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Decode password



shahin
  • profile picture
  • Member

Posted 21 May 2012 - 06:03 AM

Hello,
I want to show password to user for edit.I kept password in database after encryption.How can I decrypt password when show in edit mode.It show encrypted password.

Thanks in advance
Shahin

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 21 May 2012 - 06:10 AM

This will help you
http://www.grocerycr...tiondecryption/

shahin
  • profile picture
  • Member

Posted 21 May 2012 - 06:26 AM

Hello,
Very very thanks.But I want to access 'password field' from a different table.That means I used $crud->set_relation().My code is like this:->
...................................................................................................................................................................................................................................
function personal_details()
{
$crud = new grocery_crud();
$crud->set_field_upload('photo', 'assets/uploads/profile_picture');
$crud->set_relation('login_id', 'login','password');
$crud->set_relation('status_id', 'status','status');
$crud->display_as('status_id','Status')->display_as('login_id','Password');
$crud->callback_edit_field('password',array($this,'decrypt_password_callback'));
$crud->unset_fields('created_at','updated_at');

$output = $crud->render();
$title = "Profile";
$this-> _example_output($output,$title);
}

function decrypt_password_callback($value)
{
$this->load->library('encrypt');
$key = 'super-secret-key';
$decrypted_password = $this->encrypt->decode($value, $key);
return "<input type='password' name='password' value='$decrypted_password' />";
}
............................................................................................................................................................................................................................................
I have two tables
1.login[list]
[*]id
[*]username
[*]password
[/list]
2.personal_details[list]
[*]id
[*]login_id(To access password)
[/list]
Egarly waiting for your response.
Thanks in advance
Shahin

umairkhan
  • profile picture
  • Member

Posted 21 May 2012 - 06:35 AM

Dear,

I think you missed


$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('[color=#282828][font=helvetica, arial, sans-serif]login[/font][/color]'); // This line......

See Example function here http://www.grocerycrud.com/documentation/options_functions/set_relation :


function employees_management()
{
$crud = new grocery_CRUD();

$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->display_as('officeCode','Office City');
$crud->set_subject('Employee');

$crud->set_relation('officeCode','offices','city');

$output = $crud->render();

$this->_example_output($output);
}


Thanks

umairkhan
  • profile picture
  • Member

Posted 21 May 2012 - 06:38 AM

Also i think it will be better if you reference your password field like "login.password" to avoid same column names collision b/w tables. Well, what issue you are facing right now?
Your callback function is get called or not?