<?php
session_start();
$digit = $_GET['num'];

	 $ciphering = "AES-128-CTR";
	  
	// Use OpenSSl Encryption method
	$iv_length = openssl_cipher_iv_length($ciphering);
	$options = 0;
	
	
	// Non-NULL Initialization Vector for decryption
	$decryption_iv = '1234567891011121';
	  
	// Store the decryption key
	$decryption_key = "DASD$#%)FDSF>DSAsd";
	  
	// Use openssl_decrypt() function to decrypt the data
	$decryption=openssl_decrypt ($digit, $ciphering, 
			$decryption_key, $options, $decryption_iv);
	  
	// Display the decrypted string
	$digit=$decryption;

 
 
 
  // Adapted for The Art of Web: www.the-art-of-web.com
  // Please acknowledge use of this code by including this header.

  // initialise image with dimensions of 120 x 30 pixels
  $image = @imagecreatetruecolor(120, 30) or die("Cannot Initialize new GD image stream");

  // set background to white and allocate drawing colours
  $background = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
  imagefill($image, 0, 0, $background);
  $linecolor = imagecolorallocate($image, 0xCC, 0xCC, 0xCC);
  $textcolor = imagecolorallocate($image, 0x33, 0x33, 0x33);

  // draw random lines on canvas
  for($i=0; $i < 6; $i++) {
    imagesetthickness($image, rand(1,3));
    imageline($image, 0, rand(0,30), 120, rand(0,30), $linecolor);
  }



  // add random digits to canvas
  
  $digit_split=str_split($digit);
  $zz=0;
  for($x = 15; $x <= 95; $x += 20) {
     $num = $digit_split[$zz];
    imagechar($image, rand(3, 5), $x, rand(2, 14), $num, $textcolor);
	$zz++;
  }

  // record digits in session variable
  $_SESSION['digit'] = $digit;

  // display image and clean up
  header('Content-type: image/png');
  imagepng($image);
  imagedestroy($image);
?>