Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

filters.encryption function syntax tag tutorial 2013 Donate at flattr Flattr this





Alert! Connect with 10,000 Chating Online. Join Now

Php filters.encryption () function

Write your php code

 
<?php ?>

Php Result


Your code below



Encryption Filters

mcrypt.* and mdecrypt.* provide symmetric encryption and decryption using libmcrypt. Both sets of filters support the same algorithms available to mcrypt extension in the form of mcrypt.ciphername where ciphername is the name of the cipher as it would be passed to mcrypt_module_open(). The following five filter parameters are also available:

Table M-1. mcrypt filter parameters

ParameterRequired?DefaultSample Values
modeOptionalcbccbc, cfb, ecb, nofb, ofb, stream
algorithms_dirOptionalini_get('mcrypt.algorithms_dir')Location of algorithms modules
modes_dirOptionalini_get('mcrypt.modes_dir')Location of modes modules
ivRequiredN/ATypically 8, 16, or 32 bytes of binary data. Depends on cipher
keyRequiredN/ATypically 8, 16, or 32 bytes of binary data. Depends on cipher

Example M-10. Encrypting file output using 3DES

<?php
$passphrase
= 'My secret';

/* Turn a human readable passphrase
* into a reproducable iv/key pair
*/
$iv = substr(md5('iv'.$passphrase, true), 0, 8);
$key = substr(md5('pass1'.$passphrase, true) .
               
md5('pass2'.$passphrase, true), 0, 24);
$opts = array('iv'=>$iv, 'key'=>$key);

$fp = fopen('secert-file.enc', 'wb');
stream_filter_append($fp, 'mcrypt.tripledes', STREAM_FILTER_WRITE, $opts);
fwrite($fp, 'Secret secret secret data');
fclose($fp);
?>

Example M-11. Reading an encrypted file

<?php
$passphrase
= 'My secret';

/* Turn a human readable passphrase
* into a reproducable iv/key pair
*/
$iv = substr(md5('iv'.$passphrase, true), 0, 8);
$key = substr(md5('pass1'.$passphrase, true) .
               
md5('pass2'.$passphrase, true), 0, 24);
$opts = array('iv'=>$iv, 'key'=>$key);

$fp = fopen('secert-file.enc', 'rb');
stream_filter_append($fp, 'mdecrypt.tripledes', STREAM_FILTER_WRITE, $opts);
$data = rtrim(stream_get_contents($fp));
fclose($fp);

echo
$data;
?>

Php filters.encryption Function syntax tag

filters.encryption php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php filters.encryption syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online