Editing Crypt

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 15: Line 15:
 
[http://www.php.net/crypt PHP crypt -- One-way string encryption (hashing)]
 
[http://www.php.net/crypt PHP crypt -- One-way string encryption (hashing)]
  
=== crypt in [[PHP]] ===
+
=== crypt in PHP ===
 +
 
 +
In [[PHP]]:
  
 
crypt() will return an encrypted string using the standard [[Unix]] [[DES]]-based encryption [[algorithm]] or alternative algorithms that may be available on the system. Arguments are a string to be encrypted and an optional salt string to base the encryption on. See the [[Unix]] [[man page]] for your crypt function for more information.
 
crypt() will return an encrypted string using the standard [[Unix]] [[DES]]-based encryption [[algorithm]] or alternative algorithms that may be available on the system. Arguments are a string to be encrypted and an optional salt string to base the encryption on. See the [[Unix]] [[man page]] for your crypt function for more information.
 
==== Multiple encryption types ====
 
  
 
On systems where the crypt() function supports multiple encryption types, the following constants are set to 0 or 1 depending on whether the given type is available:
 
On systems where the crypt() function supports multiple encryption types, the following constants are set to 0 or 1 depending on whether the given type is available:
Line 33: Line 33:
  
 
Note: There is no decrypt function, since crypt() uses a one-way algorithm.
 
Note: There is no decrypt function, since crypt() uses a one-way algorithm.
 
==== Examples ====
 
  
 
<pre>
 
<pre>
 
Example 1. crypt() examples
 
Example 1. crypt() examples
 
 
<?php
 
<?php
 
$password = crypt('mypassword'); // let the salt be automatically generated
 
$password = crypt('mypassword'); // let the salt be automatically generated
Line 52: Line 49:
  
 
Example 2. Using crypt() with htpasswd
 
Example 2. Using crypt() with htpasswd
 
 
<?php
 
<?php
 
// Set the password
 
// Set the password
Line 97: Line 93:
  
 
----
 
----
 
 
=== Using <nowiki><crypt></nowiki> on this wiki ===
 
=== Using <nowiki><crypt></nowiki> on this wiki ===
  

Please note that all contributions to s23 are considered to be released under the Creative Commons Attribution Share Alike (see s23:Copyrights for details) unless another license is specified on a specific page. If you don't want your writing to be edited mercilessly and redistributed at will, then don't submit it here.
When uploading your own work you can choose from different cc license types, a GNU license like GFDL or you can declare it entirely Public domain. Use the according license template on a page. If no specific license is specified, Creative Commons Attribution Share Alike will apply. You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!

Cancel Editing help (opens in new window)