Re: How to encrypt a string in php ?

Alles, was PHP betrifft, kann hier besprochen werden.

Re: How to encrypt a string in php ?

Postby Jerrypetersons » 19. October 2010 13:36


you can use the crypt() PHP function to encrypt the string .

For e.g.,

$Str = crypt('demostring');
print $Str. “ is the encrypted version of demostring”;

its only one encryption algorithm. we can decrypt the string by using this function.
crypt() function used DEC algorithm.
Posts: 2
Joined: 19. October 2010 13:19

Re: How to encrypt a string in php ?

Postby kevinedenmarg » 28. November 2010 13:12

Well, there are some pretty good libraries out there. I think it is easy to see how to use this function.If you want secure passwords, the best way would be to use some very resilient hashing algorithm.
Posts: 3
Joined: 28. November 2010 12:33

Re: How to encrypt a string in php ?

Postby steven_elvisda » 04. March 2011 16:08

is there any method that can we create encryption code by ourself? I had tried with with md5() but I could not decryption it back for password.
could you please give me and idea all?

Kindly Regards,
Posts: 2
Joined: 04. March 2011 15:26

Re: How to encrypt a string in php ?

Postby WilliL » 04. March 2011 17:30

I use RC4 de/encryption in these cases.
you'll find pure php-code
reason: it works with special german letters.

With passwords I use md5 / sha (no decryption). In my database the hashed password+salt is saved.
Posts: 636
Joined: 08. January 2010 10:54
XAMPP Version: 5.6.3
Operating System: Win7Home Prem 64 SP1

Re: How to encrypt a string in php ?

Postby johnwright456 » 31. May 2011 10:39

Try this code.....

// String EnCrypt + DeCrypt function
// Author: halojoy, July 2006
function convert($str,$ky=''){
if($ky=='')return $str;
if(strlen($ky)<8)exit('key error');
return $str;

// Secret key to encrypt/decrypt with
$key='mysecretkey'; // 8-32 characters without spaces

// String to encrypt
$string1='To be or not to be, that is the question';

// EnCrypt string

// DeCrypt back

// Test output
echo '<span style="font-family:Courier">'."\n";
echo 'Key: '.$key.'<br>'."\n";
echo $string1.'<br>'."\n";
echo $string2.'<br>'."\n";
echo $string3.'<br>'."\n";
echo '</span>'."\n";
Posts: 3
Joined: 31. May 2011 10:28

Return to PHP

Who is online

Users browsing this forum: No registered users and 1 guest