Menu

Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Friday, March 29, 2013

Fixing filename encoding using a PHP console script

Recently i had received an archive with files required for a project. It was awful. The filenames were in ciryllic and on top of that the encoding was broken. So what to do when something like this happens? I wrote a little php script that walks all directories and files and renames the files with the appropriate encoding:

Friday, March 15, 2013

Using compression in REST communication between applications

When you are working on a large project, there are alot of situations that the project is composed of more than one application. The problem here is how to solder everything together. There are alot of ways you can handle communication between applications, for example you can use XML, JSON, HTTP Requests, etc. If you are using PHP for building your project maybe the easiest way of handling communication is by using JSON.
There are two buildin function that you need to look at before starting:
We will use these two functions to serializing and deserializing the data that we need to send between applications.

Tuesday, November 6, 2012

Securing your data using PHP and OpenSSL


I saw that there wasn’t alot of information on the internet about how to encrypt data in your web application using php an openssl, so here it is.
First of all you need to understand how ssl connections works. If you already know that just skip this part:
The secured socket layer or ssl has many applications, but mostly it is used for creating an encrypted data tunnel between two remote machines.
1. The client application sends a handshake request to the remote server;
2. The server sends the ssl certificate information along with his public key;
3. The client application checks the hostname, expiration date, and authority registration of the certificate, and if some of these parameters is not met then a warning message is displayed to the user.
4. After receiving the public key form the server the client application generates an envelope key that is used to encrypt the data transfer between the two machines. This key is then encrypted with the server’s public key and send back to the server.
5. The envelope key can be decrypted only with the private key that server has.
6. After both machines have the envelope the data transfer can begin.