Jump to content

[SOLVED] Need help with encryption


david212

Recommended Posts

Hello! I need help with this one. So i have password:

 

1234 and in this encryption it looks like:

 

A65A65cB5A65

 

i mean :

 

A65A65cB5A65

1  2    3   4

 

i mean 3 characters por one letter, can anyone help me how to create a code for this encryption in php? Or maybe there is some source or tutorial . Thanx  :)

Link to comment
Share on other sites

You can not use your logic, as a real security code, in php imposable,

 

Numbers and letters mean a lot more, then what your doing, to be classed as a security codded code like md5.

 

your never achieve the end result like md5.

 

 

There are real reason why there are built in function in php, use them.

Link to comment
Share on other sites

You can not use your logic, as a real security code, in php imposable,

 

Numbers and letters mean a lot more, then what your doing, to be classed as a security codded code like md5.

 

your never achieve the end result like md5.

 

 

There are real reason why there are built in function in php, use them.

 

 

i understand but i don't want this one to create a security, i just need to know how to calculate it using php, nothing more

Link to comment
Share on other sites

U can try this

$array={1 => "A65", 2=> "A66",............,a=>"B65",b=>"B66",.......A=> "C65",B=>"C66",..............}; //You should define encode string for all the possible characters 
$string="password2";
$encode_string="";
for($i=0;i<=strlen($string);i++)
{
foreach($Array as $key => $value) 
{
if($string{i}==$key)
$encode_string=$encode_string+$value;
}
}

echo $encode_string;

I am telling you this is the weird way of doing things ............. 8)

Link to comment
Share on other sites

If you want you can try using a different number base. Do something simple like XOR the ASCII value of the character against an 8-bit mask and then convert the resultant value to a different base, like base 6. This should be low enough to give 3 digits for each ASCII code.

Link to comment
Share on other sites

If you want you can try using a different number base. Do something simple like XOR the ASCII value of the character against an 8-bit mask and then convert the resultant value to a different base, like base 6. This should be low enough to give 3 digits for each ASCII code.

 

 

Can you tell me how can i do this one? Or where i can find some tuto about this? because, i think i need this one you are telling .... Thanx

Link to comment
Share on other sites

$array={'1' => "A65", '2'=> "A66",............,'a'=>"B65",'b'=>"B66",.......'A'=> "C65",'B'=>"C66",..............}; //You should define encode string for all the possible characters 
$string="password2";
$encode_string="";
for($i=0;i<=strlen($string);i++) {
   $char = $string{$i};
   $encode_string .= $array[$char];
}

echo $encode_string;

 

But please enlighten us why you need to do this

Link to comment
Share on other sites

lol so, there is one chat, where you can create your own chat rooms, with password and access. They gave all code, room ID, also how to generate user ID, but nothing about the encryption they use to register nicknames. So i've already done the chat window with all frames to put it on my server, but with my server people onlye can login with single nicks, because i have not the encryption function and i cant create another login area for registered users. Thats all :)

Link to comment
Share on other sites

This is really basic, U should look at pagination which is the same process, or alternating color sequences.

How to slice up 500+ messages to 25 per page.

 

The whole thing is about keeping a counter.

<?php

$text="A65A65cB5A65"
$key="1234"
$max=3;  // Three Character max per key
$klen = len($key); 
$ctr=0; // Yes our counter;

$kpos=0; // Key Position
$et = ''; // Encryted Text
for($i=0;$i<len($text);$i++)
{
   $tc = substr($text,$i,1);  // Grab 1 char from text
   $kc = substr($key,$kpos,1); // Grab 1 char from key
   $nc = ord($tc) ^ ord($kc);  // Simple encryption logic, get ascii values and xor them
   $et .= $nc ; // Add it to our encrypted string

   $ctr++;
   if($ctr==$max) { have we reached our max limit
        $ctr=0; //reset our counter;
        $kpos++; // increment our key position
        if($kpo>=$klen)) $kpos=0; // if we are over our key, reset to beginning
   }
}

 

I think that shud work as is, but this is not tested.

 

using a xor to encrypt is very simple method indeed, but it works, and ya can use the same method to decrypt the encrypted text with the same key.

 

Good Luck

Link to comment
Share on other sites

This is really basic, U should look at pagination which is the same process, or alternating color sequences.

How to slice up 500+ messages to 25 per page.

 

The whole thing is about keeping a counter.

<?php

$text="A65A65cB5A65"
$key="1234"
$max=3;  // Three Character max per key
$klen = len($key); 
$ctr=0; // Yes our counter;

$kpos=0; // Key Position
$et = ''; // Encryted Text
for($i=0;$i<len($text);$i++)
{
   $tc = substr($text,$i,1);  // Grab 1 char from text
   $kc = substr($key,$kpos,1); // Grab 1 char from key
   $nc = ord($tc) ^ ord($kc);  // Simple encryption logic, get ascii values and xor them
   $et .= $nc ; // Add it to our encrypted string

   $ctr++;
   if($ctr==$max) { have we reached our max limit
        $ctr=0; //reset our counter;
        $kpos++; // increment our key position
        if($kpo>=$klen)) $kpos=0; // if we are over our key, reset to beginning
   }
}

 

I think that shud work as is, but this is not tested.

 

using a xor to encrypt is very simple method indeed, but it works, and ya can use the same method to decrypt the encrypted text with the same key.

 

Good Luck

 

Thanx a lot . it would be something like this :

 

<?php
$text="A65A65cB5A65";
$key="1234";
$max=3;  // Three Character max per key
$klen = len($key); 
$ctr=0; // Yes our counter;

$kpos=0; // Key Position
$et = ''; // Encryted Text
for($i=0;$i<len($text);$i++)
{
   $tc = substr($text,$i,1);  // Grab 1 char from text
   $kc = substr($key,$kpos,1); // Grab 1 char from key
   $nc = ord($tc) ^ ord($kc);  // Simple encryption logic, get ascii values and xor them
   $et .= $nc ; // Add it to our encrypted string

   $ctr++;
   if($ctr==$max) { //have we reached our max limit
        $ctr=0; //reset our counter;
        $kpos++; // increment our key position
        if($kpo>=$klen) $kpos=0; // if we are over our key, reset to beginning
   }
}

?>

 

but it gives Fatal error: Call to undefined function len()  on line 5 .

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.