从 C# 应用程序读取 PHP 响应的安全方法
正如该主题的标题所暗示的那样,我的服务器上设置了一个 PHP 脚本,当被调用时,它会通过将数据回显到页面上来将数据返回给用户。然后,我使用 HttpWebRequest 读取 PHP 脚本放入页面的数据。虽然此数据已加密,但我希望它根本不会出现在页面上。我想一定有更好的方法来做到这一点。
如果到目前为止我还不清楚我的意图,我正在寻找某种方法从 PHP 页面返回数据,以便我可以使用 HTTPWebResponse
检索它。例如,也许我可以发布数据?我对 PHP 很陌生,所以我想我应该询问这里的专家。
谢谢你的帮助,
埃文
As the title of the topic may suggest, I have a PHP script setup on my server that, when called upon, is spitting data back to the user by echoing it back onto the page. I am then using HttpWebRequest
to read the data that was put onto the page by the PHP script. While this data is encrypted, I would like for it to not appear on the page at all. I figured there must be a better way to go about doing this.
If I have been unclear thus far regarding my intentions, I am looking for some way to return data from a PHP page, so that I can retrieve it using HTTPWebResponse
. Perhaps, for example, I could POST the data? I'm quite new to PHP so I figured I'd ask the experts here.
Thank you for any help,
Evan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为最好的安全方法是在.NET 中使用 RSA 加密。您可以在此处阅读和下载项目
I think the best safe way is use RSA Encrypt in .NET. You can read and download project at here
您无法将数据发布到应用程序,除非该应用程序是网络服务器。除了您已经这样做的方式之外,实际上没有其他方法可以做到这一点。
You can't post the data to the application, unless the application was a webserver. There's not really much other way to do it than the way you are doing it already.
好吧,由于您使用的是 http,因此在 php 脚本中回显请求流中的数据是合乎逻辑的。这样另一边(您的 .NET 代码可以拾取它)。如果这对您来说是个问题,有一些解决方法。
a:使用指向您的 .NET 应用程序的回调 URL 从 .NET 调用您的 PHP 脚本。现在 PHP 脚本实际上可以将数据发送回回调 url。然而,这需要您的 .NET 应用程序托管 Web 服务。
b:您可以将某些数据放入您的 php 脚本中,而无需将其实际放入请求正文中,只需将其设置为 mime 标头字段,例如:
希望这会有所帮助
Well, Since you're using http, it's logical to echo the data in the request stream within your php script. This way the other side (your .NET code can pick it up). If this is a problem for you, there are a few workarounds.
a: call your PHP script from .NET with a callback url refering back to your .NET application. Now the PHP script can actually post data back to the callback url. This however requires your .NET app to host a webservice.
b: you can put certain data in your php script without actually putting it in the request body by making it a mime header field like:
Hope this helps