Ancient crypto in php menu

Shout-Out

User Tag List

Results 1 to 2 of 2
  1. #1
    Gravecorp's Avatar Member
    Reputation
    11
    Join Date
    Oct 2008
    Posts
    26
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ancient crypto in php

    A lot of people might find it useless but its something i made when i first started learning php.
    Yes i know the code isn't that good. But i was learning back then.

    Its a simple php implementation of a text cipher crypto that was from the time of the romans.

    Hence the name of the cipher: Ceasar

    How the cipher works is you have the standard alphabet and a number you call the key. For instance you take the number 3 to use that key for the cipher you move every character up the number of spaces in the alphabet table.
    a -> d, b -> e, c -> f
    And so on.
    Its extremely simple source and simple form provided.
    A lot of cryptology is based on this simple concept. And with that i don't mean the advanced cryptology(its moved beyond this). But for example the cipher text crypto's and things like base64 encoding.

    Code:
    <?php
    $word = '';
    $result = '';
    $mod = 0;
    
    if (isset($_POST['word'])) 
    {
    	$word = $_POST['word'];
    	$savedWord = 'value=\''.$_POST['word'].'\'';
    }
    
    if (isset($_POST['mod'])) 
    {
    	$mod = $_POST['mod'];
    }
    
    if (isset($_POST['action']) && $_POST['action'] == 'cipher')
    {
    	$length = strlen($word);
    	while($mod > 26)
    	{
    		$mod = $mod-26;
    	}
    	for($i=0;$i<$length;$i++) {
    		$cclass = ord($word[$i]);
    		if($cclass > 64&& $cclass < 91) {
    			$cclass = $cclass + $mod;
    			if($cclass > 90) {
    				$cclass = $cclass-26;
    			}
    		}elseif($cclass > 96 && $cclass < 123) {
    			$cclass = $cclass + $mod;
    			if($cclass > 122) {
    				$cclass = $cclass-26;
    			}
    		}elseif($cclass == 32) {
    			$cclass = 32;
    		}else{
    			$cclass = 0;
    		}
    		$result .= chr($cclass);
    	}
    }
    elseif ($_POST['action'] == 'showall') 
    {
    	$length = strlen($word);
    	while($mod > 26) 
    	{
    		$mod = $mod-26;
    	}
    	for($mod=0;$mod<26;$mod++){
    		if($mod < 10) {
    			$result .= 'Option 0'.$mod.': ';
    		}else{
    			$result .= 'Option '.$mod.': ';
    		}
    		for($i=0;$i<$length;$i++) {
    			$cclass = ord($word[$i]);
    			if($cclass > 64&& $cclass < 91) {
    				$cclass = $cclass + $mod;
    				if($cclass > 90) {
    					$cclass = $cclass-26;
    				}
    			}elseif($cclass > 96 && $cclass < 123) {
    				$cclass = $cclass + $mod;
    				if($cclass > 122) {
    					$cclass = $cclass-26;
    				}
    			}elseif($cclass == 32) {
    				$cclass = 32;
    			}else{
    				$cclass = 0;
    			}
    			$result .= chr($cclass);
    		}
    		$result .= '<br />';
    	}
    }
    ?>
    
    <html>
    	<head>
    		<title>Simple Ceasar script example</title>
    	</head>
    	<body>
    		<form action='<?PHP echo $PHP_SELF;?>' method='post'>
    			<input type='text' name='word' id='word' <?php echo $savedWord; ?> />Text<br />
    			<input type='text' name='mod' id='mod' maxlength='3' value='<?php echo $mod; ?>' />Mod = 1-26(+)<br />
    			<select name='action' id='action'>
    				<option value='cipher'>Ciphertext it!</option>
    				<option value='showall'>Show all ciphers possible</option>
    			</select>
    			<input type='submit' value='ciphertext it!' />
    		</form>
    		
    		<p><?php echo $result; ?></p>
    	</body>
    </html>
    Its that easy. Only supports characters a-z both capital and non capital.

    Ancient crypto in php
  2. #2
    Sonic Waffle's Avatar Contributor
    Reputation
    170
    Join Date
    Dec 2007
    Posts
    990
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's pretty cool actually.
    Uploaded for anyone if they wish to try it.
    Simple Ceasar script example


Similar Threads

  1. .php problems
    By Etaile in forum Community Chat
    Replies: 6
    Last Post: 07-31-2010, 07:03 PM
  2. Reqest: Steelhawk Crossbow --> Rhok'delar, Longbow of the Ancient Keepers
    By hamora in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 06-09-2007, 10:04 PM
  3. Ancient Lichen farming (Slave Pens)
    By Wombol in forum World of Warcraft Guides
    Replies: 3
    Last Post: 03-22-2007, 11:02 AM
  4. wsg bow -> strikers mark or ancient bone
    By Dregash in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 01-07-2007, 06:24 PM
  5. Hey PHP People!
    By Tory in forum Community Chat
    Replies: 0
    Last Post: 09-30-2006, 07:40 PM
All times are GMT -5. The time now is 10:45 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search