Hello ..
We had implement some what near to transpostion cipher in order to encrypt passwords and credit card number in our web site ..
We had used codes aplicable only to fixed size password to be matched with the fixed key length !
All what we need is how to encrypt a password of size (6-14) using a fixed key of length 6 ?!
how to make an array of [3] rows and [6] column for encyption ?!
ex:
password: memebeauty9090
Key: 1 2 6 3 5 4
m e m e b e
a u t y 9 0
9.0 x x x x
this is our encryption code , where to use an array and how?! ,
<?php
function encrypt($pass)
{
$passlength = strlen($pass); // check the length of the password
$pass= str_split($pass); // create an array of all letters
$ekey = '126354'; // example key, you can replace it with any key you want, not limited to 6
$ekeylength = strlen($ekey); // check the length of the key
$ekey = str_split($ekey); // create an array of all numbers in the key
$newpass = ''; // initiate the encrypted password variable
if($passlength == $ekeylength)
{ // do a loop if password length is equal to key length
for($x=1; $x<=$ekeylength; $x++)
{
$newpass .= $pass[$ekey[$x-1]-1]; // do a loop to create the new ecrypted password based on the key provided
}
}
else
{
for($x=1; $x<=$ekeylength; $x++)
{ // do a loop to replace any missing value with x. You can replace x with anoy other characters
if($x > $passlength)
$pass[$x-1] = '()@';
}
for($x=1; $x<=$ekeylength; $x++)
{ // do a final loop to create the new ecrypted password based on the key provided
$newpass .= $pass[$ekey[$x-1]-1];
}
}
return ($newpass);
}
?>
We are also finding difficulty to apply decryption ( reverse of this code) !
please help

..