using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string text;
List<byte> data = new List<byte>();
try
{
string filename = Path.GetFileNameWithoutExtension(args[0]);
string dirname = Path.GetDirectoryName(args[0]);
using (StreamReader sr = new StreamReader(
args[0], Encoding.GetEncoding("Shift_JIS")))
{
text = sr.ReadToEnd();
}
text = text.Replace(" ", "").Replace("\r", "").Replace("\n", "");
for (int i = 0; i < text.Length - 1; i = i + 2)
{
string buf = text.Substring(i, 2);
data.Add(Convert.ToByte(buf, 16));
}
byte[] bytesData = data.ToArray();
using (FileStream fs = new FileStream(dirname + @"\" + filename + @".rar",
FileMode.Create, FileAccess.Write))
{
byte[] bs = new byte[fs.Length];
fs.Write(bytesData, 0, bytesData.Length);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLlRleHQ7CnVzaW5nIFN5c3RlbS5JTzsKCm5hbWVzcGFjZSBDb25zb2xlQXBwbGljYXRpb24yCnsKICAgIGNsYXNzIFByb2dyYW0KICAgIHsKICAgICAgICBzdGF0aWMgdm9pZCBNYWluKHN0cmluZ1tdIGFyZ3MpCiAgICAgICAgewogICAgICAgICAgICBzdHJpbmcgdGV4dDsKICAgICAgICAgICAgTGlzdDxieXRlPiBkYXRhID0gbmV3IExpc3Q8Ynl0ZT4oKTsKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHN0cmluZyBmaWxlbmFtZSA9IFBhdGguR2V0RmlsZU5hbWVXaXRob3V0RXh0ZW5zaW9uKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgc3RyaW5nIGRpcm5hbWUgPSBQYXRoLkdldERpcmVjdG9yeU5hbWUoYXJnc1swXSk7CiAgICAgICAgICAgICAgICB1c2luZyAoU3RyZWFtUmVhZGVyIHNyID0gbmV3IFN0cmVhbVJlYWRlcigKICAgICAgICAgICAgICAgICAgICBhcmdzWzBdLCBFbmNvZGluZy5HZXRFbmNvZGluZygiU2hpZnRfSklTIikpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHRleHQgPSBzci5SZWFkVG9FbmQoKTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICB0ZXh0ID0gdGV4dC5SZXBsYWNlKCIgIiwgIiIpLlJlcGxhY2UoIlxyIiwgIiIpLlJlcGxhY2UoIlxuIiwgIiIpOwogICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCB0ZXh0Lkxlbmd0aCAtIDE7IGkgPSBpICsgMikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgYnVmID0gdGV4dC5TdWJzdHJpbmcoaSwgMik7CiAgICAgICAgICAgICAgICAgICAgZGF0YS5BZGQoQ29udmVydC5Ub0J5dGUoYnVmLCAxNikpOwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIGJ5dGVbXSBieXRlc0RhdGEgPSBkYXRhLlRvQXJyYXkoKTsKCiAgICAgICAgICAgICAgICB1c2luZyAoRmlsZVN0cmVhbSBmcyA9IG5ldyBGaWxlU3RyZWFtKGRpcm5hbWUgKyBAIlwiICsgZmlsZW5hbWUgKyBAIi5yYXIiLAogICAgICAgICAgICAgICAgICAgIEZpbGVNb2RlLkNyZWF0ZSwgRmlsZUFjY2Vzcy5Xcml0ZSkpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgYnl0ZVtdIGJzID0gbmV3IGJ5dGVbZnMuTGVuZ3RoXTsKICAgICAgICAgICAgICAgICAgICBmcy5Xcml0ZShieXRlc0RhdGEsIDAsIGJ5dGVzRGF0YS5MZW5ndGgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoZS5NZXNzYWdlKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQ==