Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP Manual > Encryption Filters





ลองใช้ค้นหาข้อมูล


   
Bookmark.

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:

mcrypt filter parameters
Parameter Required? Default Sample Values
mode Optional cbc cbc, cfb, ecb, nofb, ofb, stream
algorithms_dir Optional ini_get('mcrypt.algorithms_dir') Location of algorithms modules
modes_dir Optional ini_get('mcrypt.modes_dir') Location of modes modules
iv Required N/A Typically 8, 16, or 32 bytes of binary data. Depends on cipher
key Required N/A Typically 8, 16, or 32 bytes of binary data. Depends on cipher

Example #1 Encrypting file output using 3DES

<?php
$passphrase 
'My secret';

/* Turn a human readable passphrase
 * into a reproducable iv/key pair
 */
$iv substr(md5('iv'.$passphrasetrue), 08);
$key substr(md5('pass1'.$passphrasetrue) . 
               
md5('pass2'.$passphrasetrue), 024);
$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 #2 Reading an encrypted file

<?php
$passphrase 
'My secret';

/* Turn a human readable passphrase
 * into a reproducable iv/key pair
 */
$iv substr(md5('iv'.$passphrasetrue), 08);
$key substr(md5('pass1'.$passphrasetrue) . 
               
md5('pass2'.$passphrasetrue), 024);
$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;
?>


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่