• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 587
  • Last Modified:

I want to encrypt and decrypt a data in PHP

Dear Experts,

I want to encrypt and decrypt a data,
what function should I use.
I want to use a key word to decrypt the data.
I use PHP.
thank you
0
BR
Asked:
BR
3 Solutions
 
ByteSleuthCommented:
Hello Buddy,

please see here:

http://www.tonymarston.net/php-mysql/encryption.html


regards

Bytes
0
 
f_o_o_k_yCommented:
You can use PHP AES Class from:

http://www.phpclasses.org/package/4238-PHP-Encrypt-and-decrypt-data-with-AES-in-pure-PHP.html

It is really easy:


<?php
include_once('./AES.class.php');

$key256 = '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4';
// =====================================================================================================
$Cipher = new AES(AES::AES256);

$content = "Alice has a cat";
print $content.'<br />';

$start = microtime(true);
$content = $Cipher->stringToHex($content);
$content = $Cipher->encrypt($content, $key256);
$end = microtime(true);
print('AES Class encryption time (256bit): '.(($end - $start)*1000).'ms <br />');
print $content.'<br />';
$start = microtime(true);
$content = $Cipher->decrypt($content, $key256);
$content = $Cipher->hexToString($content);
$end = microtime(true);
print('AES Class decryption time (256bit): '.(($end - $start)*1000).'ms <br />');
print $content.'<br />';

?>

Open in new window

0
 
Loganathan NatarajanLAMP DeveloperCommented:
try these,
example 1
example 2
0
 
BRMarketingAuthor Commented:
thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now