PHP Classes

File: cryptedPass.inc.php

Recommend this page to a friend!
  Packages of Ismet Ozalp   Encryption and Decryption with Rijndael 256   cryptedPass.inc.php   Download  
File: cryptedPass.inc.php
Role: Class source
Content type: text/plain
Description: Main Class File
Class: Encryption and Decryption with Rijndael 256
Encrypt and decrypt data with Rijndael algorithm
Author: By
Last change: Minor bug fixed
Date: 17 years ago
Size: 1,419 bytes
 

 

Contents

Class file image Download
<?
///////////////////////////////////////////////////
//    A Encryption/Decryption CLASS with Rijndael 256    
//    By Ismet Ozalp
//  16.03.2005
//  Please Do not remove this header
///////////////////////////////////////////////////
class pWord {
    var $mykey = "THISisMyKey";
    function getEncryptedPass($len){
        $pass = $this->makeRandomPassword($len);
        return $this->linencrypt($pass);
    }
    function linencrypt($pass) {
        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); //get vector size on ECB mode 
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); //Creating the vector
        $cryptedpass = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $this->mykey, $pass, MCRYPT_MODE_ECB, $iv); //Encrypting using MCRYPT_RIJNDAEL_256 algorithm 
    return $cryptedpass;
    }

    function lindecrypt($enpass) {
        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); 
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        $decryptedpass = mcrypt_decrypt (MCRYPT_RIJNDAEL_256, $this->mykey, $enpass, MCRYPT_MODE_ECB, $iv); //Decrypting...
    return rtrim($decryptedpass);
    }
    function makeRandomPassword($len) { 
          $salt = "ABCDEFGHJKLMNPRSTUVWXYZ0123456789abchefghjkmnpqrstuvwxyz"; 
          srand((double)microtime()*1000000); 
        for($i = 0;$i < $len;$i++) { 
            $num = rand() % 56; 
            $tmp = substr($salt, $num, 1); 
            $pass = $pass . $tmp; 
        } 
    return $pass; 
    }
} 
?>