《Perl 语言入门(第五版)》

23 October 2009

《Perl 语言入门(第五版)》

Translated by chunzi, joe.jiang and cnhackTNT


Canon IXUS 95 IS

26 September 2009

I bought a digit camera today: Canon IXUS 95 IS (Chinese).

not so bad. :)

OpenSocialX::Shindig::Crypter short story

17 September 2009

the short story is that I released the OpenSocialX::Shindig::Crypter yesterday.

the short story is if you want to find a way that encrypt data by Perl and decrypt the encrypted data by PHP, you come to the right place.

Perl: crypt.pl
my $str = 'o=1&v=3&p=5';
my $cipher = Crypt::CBC->new( {
    'key' => 'length16length16',
    'cipher'=> 'Rijndael',
    'iv' => '1234567890abcdef',
    'literal_key' => 1,
    'padding' => 'null',
    'header' => 'none',
    keysize => 128/8
} );
my $encrypted = $cipher->encrypt($str);
print "encrypted: ".encode_base64($encrypted)."\n";
print "decrypted: ".$cipher->decrypt($encrypted)."\n";

my $hmac = Digest::SHA::hmac_sha1($encrypted, 'hmackey');
print "hmac: " . encode_base64($hmac) . "\n";
print "total: " . encode_base64($encrypted . $hmac) . "\n";
PHP: crypt.php
$str = 'o=1&v=3&p=5';
$encrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128, 'length16length16', $str, MCRYPT_ENCRYPT, '1234567890abcdef');
$decrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128, 'length16length16', $encrypted, MCRYPT_DECRYPT, '1234567890abcdef');
echo "encrypted: ".base64_encode($encrypted)."\n"; 
echo "decrypted: ".$decrypted."\n"; 

$blabla = hash_hmac('sha1', $encrypted, 'hmackey', 1);
echo "hmac: " . base64_encode($blabla) . "\n";
echo "total: " . base64_encode($encrypted . $blabla) . "\n";

both of them show the same output:
# perl crypt.pl
encrypted: rgPZe6swWb3t3yIoIZFQaQ==
decrypted: o=1&v=3&p=5
hmac: WLTGeyesYTUhwg6fjVqDudrKRz0=
total: rgPZe6swWb3t3yIoIZFQaVi0xnsnrGE1IcIOn41ag7naykc9
# php crypt.php
encrypted: rgPZe6swWb3t3yIoIZFQaQ==
decrypted: o=1&v=3&p=5
hmac: WLTGeyesYTUhwg6fjVqDudrKRz0=
total: rgPZe6swWb3t3yIoIZFQaVi0xnsnrGE1IcIOn41ag7naykc9

I'll post a long story later today.


OpenSocialX::Shindig::Crypter long story

17 September 2009

The long story is

we (Zorpia) were developing OpenSocial in last days. The first choice to build a opensocial container is Shindig.

unlucky, it ONLY has PHP and Java version. yeah, I do all my code in Perl, I know nothing about PHP or Java. (well, I know a little PHP now because I was writing Service package with PHP in last days, and I must say, PHP sucks.)

lucky, the Shindig author points me to an URL: Using Shindig in a non PHP or Java environment
that I can write the 'Application' section in Perl. It IS great, really very great.

so at last, I google around and wrote my last solution: OpenSocialX::Shindig::Crypter and the php lib BasicBlobCrypter.php

and now I'm happy to share it with your guys. if you have the same situation with me, you can try that module and tell me your feeling. :)

Thanks. (OK, it's not so long.)

use Moose; or no Moose;

03 September 2009

recently "Moose or no Moose" is spreading to the Perl world.

Moose or No Moose
Command Line Moose or Knowing what You Don't know.
Re: Moose Or No Moose
Take arms against a sea of troubles
Re: Re: Moose Or No Moose
Moose Startup Time over Time

basically I agree with Adam Kennedy that Array::Compare shouldn't based on Moose. Test::Warn is a popular module and Array::Compare without Moose can totally ease the install of the Test::Warn.

in the meantime, I would agree with Stevan Little that we shouldn't hold the usage of the Moose. it's a great module with great idea and great contributors. I use it in my daily life and it works great. once more and more people/module use Moose, the problem wouldn't become a problem.

I think Padre should use Moose, I know Adam would reject that, but I insist on that Padre will benefit from Moose even Class::XSAccessor is the fastest accessor module now. Padre will be in a better structure and much more easy to read if it's coded with Moose. Plugin/Document/Highlighter would be easily written and plugged.

another thing is that I met the problem before. Long time ago people rate down WWW::Contact because it uses Moose. but I think it's not true. Moose helps me to build the module.

at last and in short, I think simple module (like only use the accessor of Moose) shouldn't use Moose but large software/module like Padre should use Moose.

Thanks. just personal thoughts.


07 August 2009

some of you may be noticed that I'm writing a free perl book in Chinese.

yeah, I released it as a CPAN module yesterday: Book::Chinese::MasterPerlToday

it's not finished yet but I promise I will. so have fun and stay tuned.

patches or suggestions are welcome. :)

The Definitive Guide to Catalyst

26 July 2009

The Definitive Guide to Catalyst: Writing Extensible, Scalable and Maintainable Perl–Based Web Applications

My boss (Jeffrey Ng) just brought this book for me (thanks to my college Calvin getting it for me from USA).

I haven't read it yet, but I will. it's a good book. I'll post a review once I read it through.


a module started with O

11 July 2009

ORDB::Unihan - An ORM for the published Unihan database

a mixin of ORLite and Unihan database. the original unihan database is txt based, and this one is sqlite.
even if you don't want to use ORLite, you still can use the Unihan.sqlite by ORDB::Unihan->sqlite_path();

bla bla, not sure how useful it is. just for fun.


QueryLog support for Catalyst::Model::DBIC::Schema

17 June 2009

well, I wrote Catalyst::Model::DBIC::Schema::QueryLog before. it's fine. it works.

mst released the new Catalyst::Model::DBIC::Schema today. built on top of Moose, with two traits: Caching and Replicated.
It reminds me to write Catalyst::TraitFor::Model::DBIC::Schema::QueryLog
trait is great. easy to read, configurable and sane.

Enjoy. Thanks

DBIx-Class talk

27 May 2009

I just gave a DBIx-Class talk on the annual meeting of Zorpia 1 hour ago. it's not a success one, but I still want to share with you. check:


Enjoy, Thanks.