Skip to content

Instantly share code, notes, and snippets.

@mgng
Created March 19, 2012 02:00
Show Gist options
  • Select an option

  • Save mgng/2090340 to your computer and use it in GitHub Desktop.

Select an option

Save mgng/2090340 to your computer and use it in GitHub Desktop.
PerlとPHPでDigest認証
<?php
echo get_htdigest('test','aaa','test');
function get_htdigest($id, $relm, $pass) {
return "$id:$relm:" . md5("$id:$relm:$pass");
}
#!/usr/bin/perl
use strict;
use warnings;
use Digest::MD5;
print get_htdigest('test','aaa','test');
sub get_htdigest {
my ($id,$relm,$pass) = @_;
my $ctx = Digest::MD5->new;
$ctx->add("$id:$relm:$pass");
return "$id:$relm:" . $ctx->hexdigest;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment