@@ -137,22 +137,40 @@ private function _submit($content)
137
137
*/
138
138
public function send ($ txBody )
139
139
{
140
+ // Convert Body to string
141
+ $ content = json_encode ($ txBody , JSON_UNESCAPED_SLASHES );
142
+
140
143
// Encrypted Connection?
141
144
if ($ this ->_pem ) {
142
- // Encrypt with the nodes public address
143
- openssl_public_encrypt (
144
- json_encode ($ txBody , JSON_UNESCAPED_SLASHES ),
145
- $ encrypted ,
146
- $ this ->_pem ,
147
- OPENSSL_PKCS1_OAEP_PADDING
148
- );
149
-
150
- // Submit Transaction as Base54 Encoded body
151
- return $ this ->_submit (base64_encode ($ encrypted ));
145
+
146
+ // Split String into encryptable chunks
147
+ $ chunks = str_split ($ content , 116 );
148
+
149
+ // Stores concatenated encrypted chunks
150
+ $ encryptedContent = "" ;
151
+
152
+ // Loop chunks and encrypt
153
+ foreach ($ chunks as $ chunk ) {
154
+ if (openssl_public_encrypt (
155
+ $ chunk ,
156
+ $ encrypted ,
157
+ $ this ->_pem ,
158
+ OPENSSL_PKCS1_PADDING
159
+ )
160
+ ) {
161
+ // Append encryption
162
+ $ encryptedContent .= $ encrypted ;
163
+ } else {
164
+ throw new \Exception ("Failed to encrypt " );
165
+ }
166
+ }
167
+
168
+ // Update Content with base64 encoded encrypted
169
+ $ content = base64_encode ($ encryptedContent );
152
170
}
153
171
154
172
// Normal Transaction Send as JSON
155
- $ response = $ this ->_submit (json_encode ( $ txBody , JSON_UNESCAPED_SLASHES ) );
173
+ $ response = $ this ->_submit ($ content );
156
174
157
175
// Did we get a response?
158
176
if ($ response && $ response ->{'$umid ' }) {
0 commit comments