?
Solved

Encryption Library for VB and PHP

Posted on 2010-01-09
7
Medium Priority
?
782 Views
Last Modified: 2013-11-18
Dear member,
Can you suggest me a strong encryption library that I can use for VB and PHP ?

I need to encrypt and decrypt text. Encryption and decryption must can be done from VB6.0 application and PHP website.
And cross process. Encrypt using VB and decrypt using PHP and otherwise.
I dont want to use .net

I dont mind a premium library or a free one.

Thank you.
0
Comment
Question by:eddysusanto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26272952
I can show you one side of the issue - this works fine in PHP.  If there is a VB programmer who can fill in the other side, you've got it!

Best regards, ~Ray
<?php // RAY_mcrypt.php
// SET OUR SECRET KEY
$key     = "Secret"; // Encryption key (http://www.ciphersbyritter.com/glossary.htm#Key)



// IF ANY THING IN POST ARRAY
if (!empty($_POST))
{
// RECOVER THE THING THAT WAS POSTED
   $cryp   = base64_decode($_POST['cryp']);
   $td     = base64_decode($_POST['td']);
   $iv     = base64_decode($_POST['iv']);
   $data   = mcrypt_decrypt($td, $key, $cryp, MCRYPT_MODE_CBC, $iv);
   $data   = trim($data);
   echo "<br/>$data \n";
}




// SET OUR ENCRYPTION / DECRYPTION VARS
$td      = MCRYPT_RIJNDAEL_256; // Encryption cipher (http://www.ciphersbyritter.com/glossary.htm#Cipher)
$iv_size = mcrypt_get_iv_size($td, MCRYPT_MODE_CBC); // Dependant on cipher/mode combination (http://www.php.net/manual/en/function.mcrypt-get-iv-size.php)
$iv      = mcrypt_create_iv($iv_size, MCRYPT_RAND); // Creates an IV (http://www.ciphersbyritter.com/glossary.htm#IV)


// SET OUR TEST STRING
$data = "Shall we eat pizza or collard greens?"; // Data to encrypt (http://www.ciphersbyritter.com/glossary.htm#Encryption)
echo "<br/>Original data: $data \n";

// ENCRYPT OUR TEST STRING
$cryp = mcrypt_encrypt($td, $key, $data, MCRYPT_MODE_CBC, $iv); // Encrypts data (http://www.php.net/manual/en/function.mcrypt-encrypt.php)

// ENCODE THE FIELDS FOR TRANSFER
$b64_cryp = base64_encode($cryp);
$b64_td   = base64_encode($td);
$b64_iv   = base64_encode($iv);

?>
<form  action="<?=$_SERVER["PHP_SELF"]?>" method="post" accept-charset="UTF-8">
<input type="text" name="cryp" value="<? echo $b64_cryp; ?>" />
<input type="text" name="td"   value="<? echo $b64_td;   ?>" />
<input type="text" name="iv"   value="<? echo $b64_iv;   ?>" />
<input type="submit" />
</form>

<?

$data = mcrypt_decrypt($td, $key, $cryp, MCRYPT_MODE_CBC, $iv); // Decrypts data (http://www.php.net/manual/en/function.mcrypt-decrypt.php)
$data = trim($data);
echo "<br/>$data \n";

Open in new window

0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 26273516
Use Blowfish - PHP has it built in to the mcrypt module and you can get VB implementations of it http://www11.brinkster.com/notbono/vb.asp

0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 26274832
Check the links below the green code block here:
http://www.chilkatsoft.com/p/php_blowfish.asp

I have not tested them together, but the page claims that they should work.
http://www.example-code.com/vb/crypt2_blowfish_matchPhp.asp

Best of luck with your project, ~Ray
0
2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 26274956
One extra point when using Blowfish - you need to send the Initialisation Vector along with the encrypted data so that the decryption can be initialised into the same state as the original when the encryption took place. The initialisation vector is NOT the key so there are no security issues with storing it with the encrypted data.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26277756
Brian - good point there about sending the IV.  In the code snippet above, we need to transmit these binary strings over the internet. That is why I have base64_encode and decode in the code snippet.  It's probably baked into the examples, but if it is not, you may want to use it.
0
 

Author Comment

by:eddysusanto
ID: 26292260
Hi guys,
Thank you. I'll try first. I'll post the result here.
0
 

Author Closing Comment

by:eddysusanto
ID: 31674977
Works great on my PHP and VB apss.
Thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The recent Petya-like ransomware attack served a big blow to hundreds of banks, corporations and government offices The Acronis blog takes a closer look at this damaging worm to see what’s behind it – and offers up tips on how you can safeguard your…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question