テキストファイルをバイトシフトする必要があります。私は perl についてまったく何も知りませんが、perl でmoz-byteshift.plという完全に機能するコードを見つけました(ドキュメンテーション)。これはまさに私がやりたいことですが、C# で行う必要があります。
perl ファイルのソース コードは次のとおりです。
#!/usr/bin/perl
# To perform a byteshift of 7
# To decode: moz-byteshift.pl -s -7 <infile >outfile
# To encode: moz-byteshift.pl -s 7 <infile >outfile
# To perform a byteshift of 13
# To decode: moz-byteshift.pl -s -13 <infile >outfile
# To encode: moz-byteshift.pl -s 13 <infile >outfile
use encoding 'latin1';
use strict;
use Getopt::Std;
use vars qw/$opt_s/;
getopts("s:");
if(!defined $opt_s) {
die "Missing shift\n";
}
my $buffer;
while(1) {
binmode(STDIN, ":raw");
my $n=sysread STDIN, $buffer, 1;
if($n == 0) {
last;
}
my $byte = unpack("c", $buffer);
$byte += 512 + $opt_s;
$buffer = pack("c", $byte);
binmode(STDOUT, ":raw");
syswrite STDOUT, $buffer, 1;
}
誰かが少なくとも perl スクリプトがどのように機能するかを説明できれば、それは素晴らしいことです。C# での同等のサンプル コードの方がよいでしょう。=)
助けてくれてありがとう。