facebook twitter hatena line email

Php/可逆暗号

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

Pear::Crypt_Blowfishを使う

install

pear install Crypt_Blowfish

sample

<?php
require_once 'Crypt/Blowfish.php';

$key = "testtest";
$text = "1234567890";

$blowfish = new Crypt_Blowfish($key);
$encrypt = base64_encode($blowfish->encrypt($text));
$decrypt = rtrim($blowfish->decrypt(base64_decode($encrypt)), "\0");

print $encrypt;
print "\n";
print $decrypt;
print "\n";