holyhippie: (Default)
[personal profile] holyhippie
Here's a snippet of code inspired by this page, on an minor technical feature of the email server I work with on a regular basis.


sub hashdir($) {
  my ($orig) = @_;
  my $hashval = 0;

  foreach my $char (split(//,$orig)) {
    use integer;
    $hashval = $hashval*31 + ord($char);
  $char1 = $hashval & 0xf;
  $hashval = $hashval >> 4;
  $char2 = $hashval & 0x7;
  $hashval = $hashval >> 3;
  $char3 = $hashval & 0xf;
  $hashval = $hashval >> 4; 
  $char4 = $hashval & 0x7;
  return sprintf ("%x%x/%x%x/", $char1, $char2, $char3, $char4);

print hashdir($ARGV[0]), "\n";
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
Account name:
If you don't have an account you can create one now.
HTML doesn't work in the subject.


Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.
Page generated Sep. 25th, 2017 08:06 am
Powered by Dreamwidth Studios