如何解密地穴(“名称”)

时间:2011-04-11 11:38:30

标签: php

如何解密crypt("name")

8 个答案:

答案 0 :(得分:16)

你做不到。来自documentation

  

注意:没有解密功能,因为crypt()使用单向算法。

阅读文档有帮助;)

答案 1 :(得分:5)

crypt是一种散列方式,你无法解密它。

如果你想将它与另一个字符串进行比较,你也可以将其加密,然后比较两个加密的字符串。

答案 2 :(得分:2)

  

crypt - 单向字符串哈希

答案 3 :(得分:2)

使用双向散列

尝试使用mcrypt

tutorial

答案 4 :(得分:0)

由于crypt()产生哈希解密是不可能的。如果您需要猜测原始数据(“名称”),您可以使用强力算法和大型字典的组合。

答案 5 :(得分:0)

我找到了mcrypt的一个例子,并为文本或二进制文件创建了两个函数:

sum(100,15) = 15 + 30 + 45 + 60 + 75 + 90

例如Crypt一个字符串:

function MyDecrypt($input,$key){    
        /* Open module, and create IV */
        $td = mcrypt_module_open('des', '', 'ecb', '');
        $key = substr($key, 0, mcrypt_enc_get_key_size($td));
        $iv_size = mcrypt_enc_get_iv_size($td);
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        /* Initialize encryption handle */
        if (mcrypt_generic_init($td, $key, $iv) != -1) {
            /* 2 Reinitialize buffers for decryption */
            mcrypt_generic_init($td, $key, $iv);
            $p_t = mdecrypt_generic($td, $input);
                return $p_t;
            /* 3 Clean up */
            mcrypt_generic_deinit($td);
            mcrypt_module_close($td);
        }
} // end function Decrypt()


function MyCrypt($input, $key){
    /* Open module, and create IV */ 
    $td = mcrypt_module_open('des', '', 'ecb', '');
    $key = substr($key, 0, mcrypt_enc_get_key_size($td));
    $iv_size = mcrypt_enc_get_iv_size($td);
    $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    /* Initialize encryption handle */
    if (mcrypt_generic_init($td, $key, $iv) != -1) {
        /* 1 Encrypt data */
        $c_t = mcrypt_generic($td, $input);
        mcrypt_generic_deinit($td);
            return $c_t;
        /* 3 Clean up */
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);
    }
}

我希望有帮助

答案 6 :(得分:0)

你无法真正解密它,因为有(无限)许多字符串crypt($input) == crypt("name") - 但你可以通过暴力试错法找到 some < / em>这些字符串。

如果您知道或怀疑原始字符串是一个简短的字典单词,并且您找到一个产生相同输出的短字典单词,那么您很可能已经解密了#34;原始字符串。

md5并且常规地以这种方式攻击许多较弱的哈希函数。

答案 7 :(得分:-2)

<?php

$hashed_password = crypt('mypassword'); // let the salt be automatically generated

/* You should pass the entire results of crypt() as the salt for comparing a
   password, to avoid problems when different hashing algorithms are used. (As
   it says above, standard DES-based password hashing uses a 2-character salt,
   but MD5-based hashing uses 12.) */
if (hash_equals($hashed_password, crypt($user_input, $hashed_password))) {
   echo "Password verified!";
}

?>