#!/usr/bin/perl
# vim: syn=perl

use strict;
use Digest::SHA1 qw(sha1_base64);

# copy/paste from https://svn.yandex.ru/verstka/tools/ycssjs/Yandex/YCssJs.pm
sub fix_base64 ($) {
    my ($base64) = @_;
    $base64 =~ s#\+#-#g;
    $base64 =~ s#/#_#g;
    $base64 =~ s#^-+##; # NONPRJ-497
    return $base64;
}

sub process_file {
    my ($file) = @_;
    my $content = do {
        open my $fh, "$file" or die "open $file failed: $!";
        local $/;
        <$fh>;
    };

    print fix_base64(sha1_base64($content));
}

process_file(shift);

