http://captcha.jp/captcha5.phpに、アカウントIDと、秘密鍵でDES暗号化した文字列を渡してください。 使用できる文字は指定するフォントによります。
<a href="http://captcha.jp/"> <img src="http://captcha.jp/captcha5.php?id=1&auth=<?= $auth ?>&size=16&font=CENTURY.TTF &filter=no&color=808080&bgcolor=EF810F&time=<?= time() ?>" alt="CAPTCHA Image"></a> |
<? // test5.php captcha sample code // DES暗号化ライブラリ require( 'des_64.php' ); // 初期化 //$base = 'あかさたなはまやらわん'; // フォントによっては日本語にも対応 $base = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $auth = ''; // アカウントID $id = ''; // DESの秘密鍵 $key = ''; // 認証 if ( $_GET['act'] == 'test' ) { $_GET['auth'] = trim( decrypt( $key, urldecode( $_GET['auth'] ) ) ); if ( strtoupper( $_GET['charenge'] ) == strtoupper( $_GET['auth'] ) ) { $message = 'CAPTCHAテストに成功しました'; } else { $message = 'CAPTCHAテストに失敗しました'; } } // captcha.phpに渡す文字列をランダムに生成し、DESで暗号化してURLエンコード $len = strlen( $base ) - 1; for ( $n = 0; $n < 6; $n ++ ) $auth .= substr( $base, rand( 0, $len ), 1 ); $auth = urlencode( encrypt( $key, $auth ) ); ?> <html> <body> <form action="test4.php" method="get"> <input type="hidden" name="act" value="test"> <input type="hidden" name="auth" value="<?= $auth ?>"> <a href="http://captcha.jp"> <img src="http://captcha.jp/captcha4.php?id=<?= $id ?>&auth=<?= $auth ?>&time=<?= time() ?>" alt="CAPTCHA Image"></a> <input type="text" name="charenge" size=8 maxlength=8> <input type="submit" value="- テスト -"> </form> <?= $message ?><br> </body> </html> |
#!/usr/bin/perl # test4.pl captcha sample code require 'cgi-lib.pl'; require 'des.pl'; # Initialize $base = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $auth = ''; $time = time(); &ReadParse( *in ); # account ID $id = ''; # secret key $key = ''; # auth if ( $in{'act'} eq 'test' ) { $in{'auth'} =~ s/\%([A-Fa-f0-9]{2})/pack('C',hex($1))/seg; $in{'auth'} = &TripleDES( $key, $in{'auth'}, 0, 0 ); $in{'auth'} =~ s/^\s|\0+//; $in{'auth'} =~ s/\s|\0+$//; if ( uc( $in{'charenge'} ) eq uc( $in{'auth'} ) ) { $message = 'CAPTCHA test succeeded'; } else { $message = 'CAPTCHA test failed'; } } # make random strings hand over to captcha.php, and DES encryption, and URL encodeing $len = length( $base ) - 1; for ( $n = 0; $n < 6; $n ++ ) { $auth .= substr( $base, int( rand( $len ) ), 1 ); } $auth = &TripleDES( $key, $auth, 1, 0 ); $auth =~ s/([^A-Za-z0-9])/sprintf('%%%02X',ord($1))/seg; print "Content-type: text/html\n\n"; print <<"_EOT_"; $org <html> <body> <form action="test4.cgi" method="get"> <input type="hidden" name="act" value="test"> <input type="hidden" name="auth" value="$auth"> <a href="http://captcha.jp/"> <img src="http://captcha.jp/captcha4.php?id=$id&auth=$auth&time=$time" alt="CAPTCHA Image"></a> <input type="text" name="charenge" size=8 maxlength=8> <input type="submit" value="- TEST -"> </form> $message<br> </body> </html> _EOT_ exit 0; |
ATASHI Networks, Inc. Labs | webarchives folksonomy | Look at me! | Captcha.jp
Copyright © 2006 ATASHI Networks, Inc. all rights reserved.