#!/usr/bin/perl # image destroy # esskar aka Sascha Kiefer for perl-community use strict; use bytes; my $secret_pbdata = "esskar aka Sascha Kiefer"; my $secret_cbdata = length $secret_pbdata; sub destroy_image { my ($file) = @_; my $image = ""; if($image = read_binfile($file)) { $image = "$_$image" foreach (split('', $secret_pbdata)); write_binfile($file, $image); } } sub fix_image { my ($file) = @_; my $image = ""; if($image = read_binfile($file)) { $image = substr($image, $secret_cbdata); write_binfile($file, $image); } } sub read_binfile { my ($file) = @_; my $data = ""; if(open(FILE, "< $file")) { binmode FILE; my ($len, $off) = (0, 0); my $buffer = ""; while($len = read(FILE, $buffer, $off)) { $data .= $buffer; $len += $off; } close(FILE); } return $data; } sub write_binfile { my ($file, $data) = @_; my $data = ""; if(open(FILE, "> $file")) { binmode FILE; print FILE $data; close(FILE); } }