Criptografia de senhas
Pessoal é o seguinte to criando um sistema, e preciso de bastante segurança para os usuários do msm.
Tentei usar OpenSSL para criptografar senha mas não obtive sucesso. Então usei um jogo de hash e mcrypter. Queria saber oque vcs acharam e se ficaria realmente seguro.
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of fun
*
* @author Big Dell
*/
class funcoes {
public function camuflaSenhas($senhas) {
try {
$camufla = md5(base64_encode($senhas));
$texto = 'Segunda parde do desafio começa aqui!' . md5($senhas);
$texto = $texto . 'Eu sei' . sha1($camufla) . 'oque';
$camufla = md5($texto);
$texto = 'Eu sei' . sha1($camufla) . 'oque' . md5($camufla) . 'você fez';
$camufla = sha1($texto);
$texto = sha1(base64_decode(sha1($camufla) . 'Eu sei' . md5($camufla) . 'oque' . sha1($camufla) . 'você fez' . md5($camufla) . 'verão passado' . sha1($camufla)));
$camufla = sha1($texto);
$texto = ' Parabens você conseguiu a senha: ' . md5($camufla);
$key1 = $camufla;
$key2 = $texto;
$input = md5($senhas);
$length = strlen($input);
/* Open the cipher */
$td = mcrypt_module_open('rijndael-256', '', 'cbc', '');
/* Create the IV and determine the keysize length, use MCRYPT_RAND
* on Windows instead */
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
$ks = mcrypt_enc_get_key_size($td);
/* Create key */
$key1 = md5($key1);
$key2 = sha1($key2);
$key = substr($key1, 0, $ks / 2) . substr(strtoupper($key2), (round(strlen($key2) / 2)), $ks / 2);
$key = substr($key . $key1 . $key2 . strtoupper($key1), 0, $ks);
/* Intialize encryption */
mcrypt_generic_init($td, $key, $iv);
/* Encrypt data */
$encrypted = mcrypt_generic($td, $input);
/* Terminate encryption handler */
mcrypt_generic_deinit($td);
/* Initialize encryption module for decryption */
mcrypt_generic_init($td, $key, $iv);
/* Decrypt encrypted string */
$decrypted = mdecrypt_generic($td, $encrypted);
/* Terminate decryption handle and close module */
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
$camufla = sha1(md5($encrypted));
return $camufla;
} catch (Exception $exc) {
echo 'Erro ao Camulhar Senha:' . $exc->getMessage();
return false;
}
}
}
uma senha gerada com o sistema: cbd6bfac19286e95824c8f222b7e44a852052f68
Discussão (6)
Carregando comentários...