我有一个base64_encoded格式的RSA公钥:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzkBJ/Wuyj0hZWa6oH+hD
+5JX1rV/TAf3lKxTPf0MUrREh2S3QPzLYBdUxByI552I3nAHJAh6JujUjGkj4O1y
X6OBJHJ596GQnv0wBUF5sr0QVg2ljav33HkuHt+otriY7jZy+OTlivkmdSdyhXht
VNlw+GgyQxeAI4f1BgaEGAfd9QJyN9yrkyZLqs9+CCmMog8ZbcqqSlR/S5nhUJku
zTD4YvmaA4okQADyOtktTCyUC3ndhRuGp451h+p5WAmcXYpW3QrqDfDzuFMy5Vlw
IB/EA9fZeMTY2tWi/7YnaVqYDJjhQv2XueOMizMCFCN2by+blc83uduPXJQpXHrV
aQIDAQAB
-----END PUBLIC KEY-----
和十六进制形式的模数:
00:ce:40:49:fd:6b:b2:8f:48:59:59:ae:a8:1f:e8:
43:fb:92:57:d6:b5:7f:4c:07:f7:94:ac:53:3d:fd:
0c:52:b4:44:87:64:b7:40:fc:cb:60:17:54:c4:1c:
88:e7:9d:88:de:70:07:24:08:7a:26:e8:d4:8c:69:
23:e0:ed:72:5f:a3:81:24:72:79:f7:a1:90:9e:fd:
30:05:41:79:b2:bd:10:56:0d:a5:8d:ab:f7:dc:79:
2e:1e:df:a8:b6:b8:98:ee:36:72:f8:e4:e5:8a:f9:
26:75:27:72:85:78:6d:54:d9:70:f8:68:32:43:17:
80:23:87:f5:06:06:84:18:07:dd:f5:02:72:37:dc:
ab:93:26:4b:aa:cf:7e:08:29:8c:a2:0f:19:6d:ca:
aa:4a:54:7f:4b:99:e1:50:99:2e:cd:30:f8:62:f9:
9a:03:8a:24:40:00:f2:3a:d9:2d:4c:2c:94:0b:79:
dd:85:1b:86:a7:8e:75:87:ea:79:58:09:9c:5d:8a:
56:dd:0a:ea:0d:f0:f3:b8:53:32:e5:59:70:20:1f:
c4:03:d7:d9:78:c4:d8:da:d5:a2:ff:b6:27:69:5a:
98:0c:98:e1:42:fd:97:b9:e3:8c:8b:33:02:14:23:
76:6f:2f:9b:95:cf:37:b9:db:8f:5c:94:29:5c:7a:
d5:69
这是我想用于签名消息的加密功能。
public function encrypt ($m, $e, $n, $s=3) {
$coded = '';
$max = strlen($m);
$packets = ceil($max/$s);
for($i=0; $i<$packets; $i++){
$packet = substr($m, $i*$s, $s);
$code = '0';
for($j=0; $j<$s; $j++){
$code = bcadd($code, bcmul(ord($packet[$j]), bcpow('256',$j)));
}
$code = bcpowmod($code, $e, $n);
$coded .= $code.' ';
}
return trim($coded);
}
现在我怎么能将十六进制值转换为十进制,它会像这样工作?请指教! 我已经通过RSA算法生成publicKey,privateKey,模数并作为魅力来测试此函数,但现在我需要使用SSL证书密钥。