Perl Topics





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Perl Tutorial
Introduction Introduction
Installing Perl Installing Perl
Basics of Perl Basics of Perl
Scalar Variables Scalar Variables
Operators Operators
Control Structures Control Structures
Lists Lists
Array Array
Arrays Manipulation Arrays Manipulation
Arrays Functons Array Functions
Hash Hash
Hash Functions Hash Functions
String Functions String Functions
Regular Expression Regular Expression
Regular Expression Functions Regular Expression Functions
Numerical Functions Numerical Functions
List Functions List Functions
User Defined Function User Defined Function
File Handling File Handling
Forums Ask Your Doubts
Feedback Feedback
 





crypt Function in Perl


Tutorials Perl

Topic

What is crypt() in Perl?



Explanation

This is used for 56 bit DES encryption,its a one way hash function. In the function plain text and salt is converted into a digest. Small changes made to the plain text or salt will have a large change in digest.

Syntax:
  crypt (plaintext, salt)

In the above syntax, this function takes two arguments first argument is "plaintext", second one is the "salt" value.

Example:
    #! C:\programfiles\perl\bin\perl
    print "content-type: text/html\n\n";
    $string = "ABV.PNT4TtMZQ";
    $string2 = "Hioxindia";
    $temp = crypt($string,'AB');
    if ($string=$string2)
     {
      print "Crypt Matches";
     }
    else
     {
      print "Crypt Dont Match";
     }
Result:
     Crypt Matches

In the above example already a string "Hioxindia", with the salt AB is encrypted and the digest is stored in "$string", then the same string "Hioxindia" and salt is explicitly encrypted.It displays an "Crypt Matches".






A Note
Simple introduction, basic CGI perl programming codes with examples. Do send your feedback or suggestions on this tutorial. This is a copyright content.

Other Links

web hosting