Tag: PHP

Swift(iOS)和PHP中AES256encryption的结果不同

我在AES256工作,能够使用不安全的通道在iOS和PHP之间进行encryption/解密。 我看到很多类似的问题,围绕关键尺寸,模式(CBC或ECB),使用随机四等。但在这种情况下,我发现了一个奇怪的行为如下。 在这两种环境中configuration: – 密钥:32字节(256位) – 块大小:128位(标准) – iv:16字节(用于testing的静态) – 模式:CBC 如果我encryption一个16或32字节的文本(以匹配AES块大小),结果在Swift和PHP是相似的,但不完全相同: key =“12345678901234567890123456789012”plainText =“12345678901234567890123456789012”iv =“1234567890123456” Swift cipher = e5RnnlJkv4QGnGhkMwfvgMHr80NWUVhbvvfCdPQ5V2KyKJTx4KfWmn4HXi4dG0b8 PHP cipher = e5RnnlJkv4QGnGhkMwfvgMHr80NWUVhbvvfCdPQ5V2I = 如您所见,密码长度和PHP Base64string的最后两个字符有所不同。 但是,如果我使用不是AES128块大小乘数的文本,让我们说“Hello World”,则漫游器环境报告以下不同(但相同大小)的密码 Swift cipher = bdwO / 5C8a + pliIoIXtuzfA == PHP密码= oPotHCkxpOwQhIaCz6hNMw == 在这两种情况下(Swift和PHP),无论明文大小如何,密码都是正确解密的。 另外,Swift结果与代码的Objective-C版本一致 附上使用的简化代码: PHP $key = "12345678901234567890123456789012"; $iv = "1234567890123456"; $plaintext = "Hello World"; […]

JSON数据从iOS到PHP脚本

我怎样才能访问一个PHP脚本,它通过http-post接收JSON数据? 我在iOS端执行以下操作: NSData *data = [NSJSONSerialization dataWithJSONObject:object options:0 error:NULL]; NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/script.php"]]; [req setHTTPMethod:@"POST"]; [req setHTTPBody:data]; [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&err]; 我如何在php脚本中访问这些数据? 换句话说,当我在php脚本中调用json_decode(…)时,是什么?

APNS + PHP“stream_socket_client():未能启用encryption”

我在使用APNS和PHP时遇到了问题,并得到以下消息: stream_socket_client(): Failed to enable crypto 这个问题有时只会发生,而其他时候则会发生推动。 由于我有一个循环的10次迭代的testing脚本,我有时会得到这个: stream_socket_client(): SSL: Connection reset by peer 我正在使用沙盒服务器tls://gateway.sandbox.push.apple.com:2195 这是我试过的: 我试图重新发布PEM和所有证书。 我玩弄了请求协议sslv3://和tls:// 。 我玩了密码(push没有密码btw) 我试图寻找一个解决scheme的计算器,没有任何工作。 检查pem文件的权限644 检查pem父目录权限755 看来,我在Google和SO上find的所有解决scheme都是有问题的人。 我觉得这个服务可能是限速吗? 因为我们等了一会儿(大约15分钟),然后再试了一遍,并能够成功推送100条消息,直到我再次开始收到这条消息。

在ios中推送通知

我是一个新的PHP和编写代码推送通知CodeGo.net,但我得到了这些erros。 这是我的模特 function sendmessage($appid, $deviceid, $status, $message) { $deviceToken = '0f744707bebcf74f9b7c25d48e3358945f6aa01da5ddb387462c7eaf61bbad78'; $message = 'My first push notification!'; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem'); //stream_context_set_option($ctx, 'ssl', 'passphrase', 'essar@123'); $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx); if (!$fp){ exit("Failed to connect: $err $errstr" . PHP_EOL); } else { print "Connection OK/n"; } echo 'Connected to […]

AFNetworking将JSON数组作为多个单项词典发布

我遇到了类似于这里讨论的问题 。 我试图将JSON发布到服务器。 这是应该工作的Objective-C代码,但不是。 我在响应对象中得到一个空数组,不知道为什么: AFHTTPRequestOperation * operation = [manager POST:uploadScriptUrl parameters:mutableJSON success:^(AFHTTPRequestOperation * operation, id responseObject) { successBlock(operation, responseObject); } failure:^(AFHTTPRequestOperation * operation, NSError * error) { failureBlock(operation, error); }]; 这个代码(从我用来上传图片的代码改编而来) KIND OF作品。 我知道这绝对不是批准的方式: AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager]; AFJSONRequestSerializer * requestSerializer = [AFJSONRequestSerializer serializer]; [requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; manager.requestSerializer = […]

应用程序与服务器端的会话pipe理

我需要创build一个基于服务器(PHP)的应用程序与iOS客户端与authintication“login”mechanisim但我不知道在iOS会话。 我的应用程序需要login到我的网站(基于PHP的网站)来获取数据。 我不知道是为iPhone客户端的会话是在服务器上保存吗? 细节: 在从iPhone客户端发送login请求到我的Web应用程序后,我想在这里创build一个会话在我的webapp(对吧?),那我的下一个请求呢? 我可以访问为第一个请求创build的同一个会话吗?换句话说:我可以在Web会话(在服务器)中共享数据,以便在iOS客户端login后发送的每个请求中都可以访问数据吗?

ORDER BY random()与SQLITE中的种子

我想实现分页随机设置 Select * from Animals ORDER BY random(SEED) LIMIT 100 OFFSET 50 我试图设置int整数和一些断裂。 不起作用 如何在sqlite中随机播种? 我正在寻找一个机会,因为类似的问题已经存在 – 抛种SQLite RANDOM() 。 我只是没有得到的PHP解决scheme。

面对ios推送通知php代码中的问题

我在php中使用这个代码… function pushnotificationios( $deviceToken, $message, $badges){ $passphrase = "12345"; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', $_SERVER['DOCUMENT_ROOT'].'/include/ck.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); $fp = stream_socket_client( "ssl://gateway.push.apple.com:2195", $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); $body['aps'] = array( //'badge' => $badges, 'badge' => "+1", 'alert' => $message['message'], 'sound' => 'default', 'content-available' => '1' ); $body['msg'] =$message; $payload = json_encode($body); $msg = […]

如何在PHP中使用fcm(firebase控制台)将推送通知发送到iphone?

从Firebase控制台发送通知通知正常工作。 我正在获取iOS设备上的推送通知。 这里是我使用的发送推送通知到iPhone使用FCM在PHP中的代码.. <?php $ch = curl_init("https://fcm.googleapis.com/fcm/send"); //The device token. $token = ""; //Title of the Notification. $title = "Carbon"; //Body of the Notification. $body = "Bear island knows no king but the king in the north, whose name is stark."; //Creating the notification array. $notification = array('title' =>$title , 'text' => $body); //This array […]

新手有使用ASIHTTPRequest上传文件的问题

我真的可以真的使用一些帮助。 我已经在使用ASIFormDataRequest进行照片上传的过程中查找了一些详细的文档(傻瓜)。 有人能通过我在这里的生活线吗? 这是什么(相关部分),虽然我知道我可能会离开。 Camera.h #import <UIKit/UIKit.h> @class ASIFormDataRequest; … Camera.m #import "Camera.h" #import "ASIHTTPRequest.h" #import "ASIFormDataRequest.h" … – (void)uploadImage:(NSData *)imageData filename:(NSString *)filename{ NSURL *url = [NSURL URLWithString:@"http://moosesightings.com/test.php"]; ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; // Upload a file on disk [request setData:imageData withFileName:filename andContentType:@"image/jpeg" forKey:@"userfile"]; [request setDelegate:self]; [request startAsynchronous]; } … – (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary […]