2016-06-25 94 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);