亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1517 | 回復(fù): 0
打印 上一主題 下一主題

create md5 v1.0 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2010-08-16 15:07 |只看該作者 |倒序?yàn)g覽
作者: reistlin
來源: http://www.reistlin.com/blog/33
更新時(shí)間: 2010.08
版權(quán)聲明: 原創(chuàng)文章.轉(zhuǎn)載請保留作者信息和原文完整.謝絕任何方式的摘要
  1. #!/usr/bin/perl -w

  2. # Name: create md5 v1.0
  3. # Author: reistlin
  4. # Website: www.reistlin.com
  5. # Hotfix: bigyong
  6. # Website: www.bigyong.com
  7. # Date: 2010.08.02

  8. use strict;
  9. use Data::Dumper;
  10. use Digest::MD5 qw(md5 md5_hex md5_base64);


  11. # Debug Switch
  12. my $debug = 0;

  13. # Start Time
  14. my $time_1 = time();
  15. # Clear
  16. system "clear";


  17. # Defined Original Hash File
  18. my $original_file = "check_md5.log";
  19. my %original_hash;

  20. # Defined CheckList Directory
  21. my $checklist_dir = "/home/reistlin";

  22. # Defined Exclude Directory
  23. my $exclude_tag = 0;
  24. my @exclude_dir = ("/home/reistlin/exclude1", "/home/reistlin/exclude2");
  25. my $exclude_key = join("|", @exclude_dir);


  26. # Create MD5 Mode
  27. sub createmd5 {
  28.         my $path = shift;
  29.         # clean path end "/"
  30.         $path =~ s/\/+$//;

  31.         opendir(DIR, $path) or die "[Error] Can not check directory [$path] \n";
  32.         my @list = readdir(DIR);
  33.         closedir(DIR);

  34.         foreach my $tmp (@list) {
  35.                 # exclude "." or ".."
  36.                 next if ( $tmp =~ m/^\.+$/ );
  37.                 # full path
  38.                 my $path_sub = $path . "/" . $tmp;
  39.                 # exclude directory
  40.                 next if ( ( $path_sub =~ /$exclude_key/ ) && ( $exclude_tag == 1 ) );
  41.                 # subdirectory recursive
  42.                 if ( -d $path_sub ) {
  43.                         &createmd5($path_sub);
  44.                 } else {
  45.                         $original_hash{$path_sub} = &md5sum($path_sub);
  46.                 }
  47.         }
  48. }


  49. # MD5 Check Mode
  50. sub md5sum {
  51.         my $file = shift;
  52.         open(FILE, $file) or die "[Error] Can not check file [$file] \n";
  53.         binmode(FILE);

  54.         my $md5 = Digest::MD5->new();
  55.         $md5->addfile(*FILE);

  56.         close(FILE);

  57.         $md5->hexdigest;
  58. }


  59. # File Stat Mode
  60. sub filestat {
  61.         my $file = shift;
  62.         my @file_stat = stat($file);
  63.         my $mtime = localtime $file_stat[9];
  64.         my $ctime = localtime $file_stat[10];

  65.         print "\n";
  66.         print "[$file] Modify: $mtime \n";
  67.         print "[$file] Change: $ctime \n";
  68.         print "[$file] UID: $file_stat[4] \n";
  69.         print "[$file] GID: $file_stat[5] \n";
  70.         print "[$file] Size: $file_stat[7] bytes \n";
  71.         print "\n";
  72. }


  73. # Main Program
  74. &createmd5($checklist_dir);


  75. # Create MD5 logfile
  76. open(LINE, "+>" . $original_file) or die "[Error] Can not create MD5 logfile [$original_file] \n";

  77. while ( my ($file, $md5) = each %original_hash ) {
  78.         print LINE "$md5 $file\n";
  79. }

  80. close(LINE);


  81. # Print Result
  82. if ( -e $original_file ) {
  83.         print "Congratulations! MD5 logfile Create Succeed! \n";
  84.         &filestat($original_file);
  85. }


  86. # End Time
  87. my $time_2 = time();
  88. my $time = $time_2 - $time_1;


  89. # Script Runtime
  90. print "Runtime \[$time\] Seconds ... \n";
  91. print "End! Good Luck! :-) \n";
  92. print "\n";
復(fù)制代碼
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP