如何将$ _GET返回到完整的字符串?它打破了我的加密密钥,因此我无法使用opnessl_public_encrypt
$key = $_GET['key'];
$key = wordwrap($key, 65, "\n", true);
$key = <<<EOF
-----BEGIN PUBLIC KEY-----
$key
-----END PUBLIC KEY-----
EOF;
原始密钥:
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgrYDLP5THYt/if+wbShGksfKjmuTe7aI4UuOHNKuONT4ROdWxfN7nn1VH3gHekYDtBRkmSmMwCQLeDzzCBP+hKT0rcfypPf6oKUlzvslOcUxOT/NPElVV7O/zPulO1kIWVHls2o3ioob8r2Bh0dFTDwj6qceTe4SaAFsPN1nSVF/w2dv53ZIO3zwXLdFHJ8dzRW25eHiWTgaIWXk4nmWcwkAE49LcfcAwXWC/Q2nd4zP3uKbi4naacqMpNj5vUPmoJg7iKodrMY4v58dmmACuMqjHjgkQeMRPQK9AV7yaMx82fhUqjA+Dx396CPTCzpk6NDSN6GDKxRzIZS5jgYyfQIDAQAB
$_GET
得到的密钥:
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgrYDLP5THYt/ifwbShGksfKjmuTe7aI4UuOHNKuONT4ROdWxfN7nn1VH3gHekYDtBRkmSmMwCQLeDzzCBP hKT0rcfypPf6oKUlzvslOcUxOT/NPElVV7O/zPulO1kIWVHls2o3ioob8r2Bh0dFTDwj6qceTe4SaAFsPN1nSVF/w2dv53ZIO3zwXLdFHJ8dzRW25eHiWTgaIWXk4nmWcwkAE49LcfcAwXWC/Q2nd4zP3uKbi4naacqMpNj5vUPmoJg7iKodrMY4v58dmmACuMqjHjgkQeMRPQK9AV7yaMx82fhUqjA Dx396CPTCzpk6NDSN6GDKxRzIZS5jgYyfQIDAQAB
某些字符如+会从字符串中删除,我该如何解决?
答案 0 :(得分:3)
您不应该在网址中传递该字符。使用urlencode()
Ref
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
你可以做(气馁):
$key = str_replace(' ','+',$_GET['key']);
答案 1 :(得分:0)
你永远不应该通过GET发送一个铭文密钥。尽可能使用POST和HTTPS。此外,由于GET变量位于URI中,因此某些字符将被删除。同样,为了避免这种情况,请使用POST。