#!/usr/bin/perl

use CGI qw(:standard);
use Digest::MD5 qw(md5_hex);
use Digest::SHA1 qw(sha1_hex);
use HTML::Escape qw(escape_html);

print header(-charset=>'utf-8');
print start_html(-bgcolor=>'#F8F4E7', -title=>'雜湊教具');

print '<h1 ALIGN="center">雜湊教具</h1>';

if (param('tf')) {
	$tf = param('tf');
	print "<H2 ALIGN=\"center\">原文：", escape_html($tf), "</H2>\n";
	print "<BLOCKQUOTE><DL>\n";

	print "<DT><B>MD5</B><BR />\n";
	print "<DD>", md5_hex($tf), "<BR /><BR />\n";

	print "<DT><B>SHA-1</B><BR />\n";
	print "<DD>", sha1_hex($tf), "<BR /><BR />\n";


	print "</DL></BLOCKQUOTE>\n";
	print hr, "\n";
}

print '您可以在下面的欄位中輸入最多 64 拜的文字，以進行雜湊示範：', br, br, "\n";

print start_form(), "\n";
print "輸入字串：<input type=\"text\" name=\"tf\" maxlength=\"64\">\n";
print submit(-value=>'雜湊'), "\n";
print " &nbsp; <INPUT TYPE=\"button\" VALUE=\"關閉\" onClick=\"window.close();\">\n";
print end_form, "\n";

print << 'END';

<!-- Light Panel for Deep Pages -->

<P><HR WIDTH=10% NOSHADE COLOR=#00BB00 ALIGN=left>
<TABLE ALIGN=center WIDTH=80% BORDER=0>
<TR><TD WIDTH=25% VALIGN=top><B>製作人、<BR>修改記錄</B></TD>
<TD WIDTH=75% VALIGN=top>
周恩冉 (2006/08/24) -- 08/12/20 (歐), 15/11/01 (單)

END

print end_html();
