Skip to main content


Showing posts from May, 2012

Public Key Infrastructure Fundamental (Part 2)

This post is a continuation (par 2) of my post that can be found here. In this post, I am going to discuss about Public Key and Private Key.

Public Key Public key can be defined as a value provided by some designated authority as an encryption key that, combined with a private key derived from the public key, can be used to effectively encrypt messages and digital signatures. Private key will be discussed below.

Private Key Private key can be defined as an encryption/decryption key known only to the party or parties that exchange secret messages.

As you can see from the above image, the public-key and private-key are both used in the encryption process in the PKI. One think you need to remember, we use the receiver's public-key as the key to encrypt the message. On the other side, the receiver, will decrypt the message using the private-key that he has.

To simplify things:
Think of a public key as being the lock. It’s not actually a key, it’s a padlock you can make lots of copies of…

Simple Paging

Paging literally means making data displayed in multiple pages. Paging is used specially for website, where displaying large amount of data can be so troublesome by making the downloaded data bigger and thus increasing the response time.

Paging can be done in many ways. In this tutorial, I would like to show you a very simple method we can use to do the paging. Here, we just need to enable the user to move to the next page (if any) and back to the previous page (if any). Also, for the sake of simplicity, I will use dummy data stored hard-codedly into an array. However, the concept is similar. OK, let's start !!!

/* Maximum number of items to show, per page */ $maxItemPerPage = 10 ; /* * Prepare the dummy data * Used just for the sake of this tutorial. */ $data = array ( ) ; for ( $i = 1 ; $i <= 112 ; $i ++ ) array_push( $data , "Item " . $i ) ; First of all, we define the maximum number of items to show per page. In t…

Faster Prime Number Checker Algorithm

Checking for prime number is actually a simple one, but can sometimes be very tricky for big number. Though there exists more powerful algorithm to check for prime number, here I want to show you one simple algorithm that is proved to be fast enough.

// // main.cpp // Prime Number Checker // // Created by Handra on 5/1/12. // Copyright (c) 2012 Handra. All rights reserved. // #include <iostream> #include <cmath> using namespace std ; /* Function prototype */ int isPrime ( int number ) ; int main ( int argc , const char * argv [ ] ) { int number = 12 ; cout << "Is Prime: " << isPrime ( number ) << endl ; return 0 ; } int isPrime ( int number ) { /* Every number below 2 is not prime */ if ( number < 2 ) return 0 ; /* Calculating the limit for denominator */ int limit = ( int ) sqrt ( number ) ; /* Start the denominator from 2. We know that every number divided by 1 must have 0 …