加密和解密md5 [英] encrypt and decrypt md5

查看:327
本文介绍了加密和解密md5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用代码 $ enrypt = md5($ pass)并将 $ encrypt 插入数据库。我想找出解密方法。我尝试使用解密软件,但它说哈希应该是正好16个字节。有没有办法解密它或使它成为一个16字节的MD5散列?



我的散列看起来像这样: c4ca4238a0b923820dcc

然而,您可以使用类似的方式安全地加密/解密密码/ etc:

  $ input =SmackFactory; 

$ encrypted = encryptIt($ input);
$ decrypted = decryptIt($ encrypted);

echo $ encrypted。 '< br />'。 $解密;

函数encryptIt($ q){
$ cryptKey ='qJB0rGtIn5UB1xG03efyCp';
$ qEncoded = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256,md5($ cryptKey),$ q,MCRYPT_MODE_CBC,md5(md5($ cryptKey))));
return($ qEncoded);
}

函数decryptIt($ q){
$ cryptKey ='qJB0rGtIn5UB1xG03efyCp';
$ qDecoded = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256,md5($ cryptKey),base64_decode($ q),MCRYPT_MODE_CBC,md5(md5($ cryptKey))),\0);
return($ qDecoded);



$ b使用加盐的加密方法更安全,下一步就是使用MD5散列。


I am using code $enrypt=md5($pass) and inserting $encrypt to database. I want to find out a way to decrypt them. I tried using a decrypting software but it says the hash should be of exactly 16 bytes. is there any way to decrypt it or to make it a 16 byte md5 hash?

My hash looks like this: c4ca4238a0b923820dcc

解决方案

As already stated, you cannot decrypt MD5 without attempting something like brute force hacking which is extremely resource intensive, not practical, and unethical.

However you could use something like this to encrypt / decrypt passwords/etc safely:

$input = "SmackFactory";

$encrypted = encryptIt( $input );
$decrypted = decryptIt( $encrypted );

echo $encrypted . '<br />' . $decrypted;

function encryptIt( $q ) {
    $cryptKey  = 'qJB0rGtIn5UB1xG03efyCp';
    $qEncoded      = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) );
    return( $qEncoded );
}

function decryptIt( $q ) {
    $cryptKey  = 'qJB0rGtIn5UB1xG03efyCp';
    $qDecoded      = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), base64_decode( $q ), MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ), "\0");
    return( $qDecoded );
}

Using a encypted method with a salt would be even safer, but this would be a good next step past just using a MD5 hash.

这篇关于加密和解密md5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆