RSA加密PHP中的字符串并将其传递给.NET服务的问题 [英] Problem with RSA-encrypting a string in PHP and passing it to .NET service

查看:150
本文介绍了RSA加密PHP中的字符串并将其传递给.NET服务的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要调用一个Web服务,需要一个包含RSA加密,base_64编码和URL编码的登录数据的登录URL。我没有正式的PHP培训,但即使对我来说似乎是一件容易的任务,但是当调用该服务时,我得到一个无效格式响应。我做错了什么,还有另一种方法来提供加密的字符串?下面的代码示例。谢谢你的帮助!

I need to call a web service that requires a login url containing an RSA encrypted, base_64 encoded and url-encoded login data. I don't have a formal php training, but even for me it seems like an easy task, however when calling the service I get an 'Invalid Format' response. What am I doing wrong and is there another way to come up with the encrypted string? Code example below. Thank you for your help!

require 'rsa.php'; // Uses rsa.php from http://www.edsko.net/misc/ for encryption.

$message = '?id=112233&param1=hello&email=hello@world.net&name=Name';

$keyLength = '2048';
$exponent = '65537';
$modulus = '837366556729991345239927764652........';
$encryptedData = rsa_encrypt($message, $exponent, $modulus, $keyLength);
$data = urlencode(base64_encode($encryptedData));

$loginurl = 'http://www.somedomain.com/LoginWB.aspx?Id=9876&Data='.$data;
echo '<iframe src="'.$loginurl.'" width="570px" height="800px">';
echo '</iframe>';


推荐答案

加密对我来说是正确的。您确定服务器没有抱怨 $ message 中的??

The encryption looks correct to me. Are you sure the server is not complaining about the '?' in the $message?

如果您关心性能,你应该使用openssl扩展。 PHP中的公钥操作非常慢。

If you care about performance, you should use openssl extensions. The public key operations are very slow in PHP.

这篇关于RSA加密PHP中的字符串并将其传递给.NET服务的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆