2016-06-25 66 views
-1

我想解密我从越狱iphone获取的密码,但我不知道为什么RNCryptor解密函数总是返回空值,当我把$ _get函数的值,但是当我把原始数据解密函数时它工作正常。任何人都有这个问题的想法? 这是为返回空值的代码:

if(isset($_GET['info'])){ 

    $password = "mykey" 
    $base64Encrypted = $_GET['info']; 
    $cryptor = new \RNCryptor\Decryptor(); 
    $plaintext = $cryptor->decrypt($base64Encrypted, $password); 
    echo $plaintext;//=> this code block return null value 

}else{ 
    echo 'not have info params'; 
} 

但是当我把原始密码数据这个代码块运行良好:

if(isset($_GET['info'])){ 

    $password = "mykey" 
    $base64Encrypted = 'AwEEeG/CU0VHXVGvuRcm805DvvVQi32NPjmlQxoaniIL9ngCjNY1Su4jEb2IfCILBvhKIdjl1znysm6SMiFmRZi2St8wCcWCmnImdwAPLysB/g=='; 
    $cryptor = new \RNCryptor\Decryptor(); 
    $plaintext = $cryptor->decrypt($base64Encrypted, $password); 
    echo $plaintext;//=> this code block return the original value of cipher 

}else{ 
    echo 'not have info params'; 
} 

回答

0

对不起,我只是firgure出了$ _GET PARAM摆明在通过URL发送时进行编码,因此所有'+'字符都已更改为空格字符。这是我的解决方案:

$password = "mykey"; 
    $stringCipher = explode('?info=', $_SERVER['REQUEST_URI'], 2); 
    $base64Encrypted = $stringCipher[1]; 
    $cryptor = new \RNCryptor\Decryptor(); 
    $decryptSerial = $cryptor->decrypt($base64Encrypted, $password);