note 91090 deleted from mcrypt.examples by danbrown
| From: | danbrown@php.net | Date: | Mon, 25 May 2009 22:08:21 +0000 |
| Subject: | note 91090 deleted from mcrypt.examples by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155970@lists.php.net to get a copy of this message | ||
Note Submitter: ricbalda at hotmail dot com
Reason: non-english
----
Hola a todos,
Después de dÃas de buscar en Google un ejemplo de como interopera VB9 con PHP encontré algo
pero con Java.
Transforme el código de Java a VB9.NET y se los pongo a su consideración:
Codigo PHP
<?php
// Encripta Mensaje y lo convierte de Bin a Hex
$cipher = "rijndael-128";
$mode = "cbc";
$plain_text = "SERIE-H23445566";
$secret_key = "01234567890abcde";
$iv = "fedcba9876543210";
$td = mcrypt_module_open($cipher, "", $mode, $iv);
mcrypt_generic_init($td, $secret_key, $iv);
$cyper_text = mcrypt_generic($td, $plain_text);
echo bin2hex($cyper_text);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
?>
<?php
// Desencripta Mensaje Oculto de Bin a Hex
$cipher = "rijndael-128";
$mode = "cbc";
$plain_text = "SERIE-H23445566";
$secret_key = "01234567890abcde";
$iv = "fedcba9876543210";
$td = mcrypt_module_open($cipher, "", $mode, $iv);
mcrypt_generic_init($td, $secret_key, $iv);
//$cyper_text = mcrypt_generic($td, $plain_text);
$decrypted_text = mdecrypt_generic($td,
hex2bin("a16ce6cefa63483f78aadc324d7bab77"));
echo ($decrypted_text);
//echo hex2bin(bin2hex($decrypted_text));
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
function hex2bin($hexdata)
{
$bindata="";
for ($i=0;$i<strlen($hexdata);$i+=2)
{
$bindata.=chr(hexdec(substr($hexdata,$i,2)));
}
return $bindata;
}
?>
Ok. Eso es todo espero que les sea de utilidad
Ricardo Balda