<?php
class shifting
{
	function Cipher($ch, $key)
	{
		if (!ctype_alpha($ch))
			return $ch;

		$offset = ord(ctype_upper($ch) ? 'A' : 'a');
		return chr(fmod(((ord($ch) + $key) - $offset), 26) + $offset);
	}

	function shiftingEncryption($input, $key)
	{
		$output = "";

		$inputArr = str_split($input);
		foreach ($inputArr as $ch)
			$output .= $this->Cipher($ch, $key);

		return $output;
	}

	function shiftingDecryption($input, $key)
	{
		return $this->shiftingEncryption($input, 26 - $key);
	}
}