Welcome Guest, Not a member yet? Register   Sign In
What are the strongest encryption/hashing functions?
#3

(This post was last modified: 03-07-2015, 05:42 AM by geekita.)

Thanks for your clarification. Here comes two use cases about hashing and encryption/decryption.

- Hash and match a password using PHP functions
PHP Code:
/* 1. "Register a new password" use case */
$submitted_password $this->input->post('password');
$password_hash password_hash($submitted_passwordPASSWORD_DEFAULT);
// Save $password_hash somewhere (database, file, etc)

/* 2. "Verify if previously saved password matches the submitted one" use case */
$submitted_password $this->input->post('password');
$password_hash = ... // Retrieve previously saved $password_hash
$password_matches password_verify($submitted_password$password_hash);

if (
$password_matches) {
    
// Access granted




- Encrypt and decrypt a string using CI Encryption library
PHP Code:
$this->load->library('encryption');

$plain_text 'This is a plain-text message!';
$ciphertext $this->encryption->encrypt($plain_text);

// Outputs: This is a plain-text message!
echo $this->encryption->decrypt($ciphertext); 

The only thing that is not so clear to me is the length of encryption key which has to be exactly or at least of 16 bytes (for AES-128 cipher).
Reply


Messages In This Thread
RE: What are the strongest encryption/hashing functions? - by geekita - 03-07-2015, 05:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB