HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2012
1009
F復号化できません3解決


F

リンク

2012/10/9(Tue) 18:43:19|NO.49888

enc.hspで変換したファイルをdec.hspで復号したいのですが、
復号に失敗するファイルがあります。

変換はおそらくうまくいっている(大きさが二倍の暗号ファイルが生成できました)
のですが、復号すると1KB以下のファイルしか生成されません。

このスクリプトなどの小さなtxtファイルの変換・復号は成功したのですが、
exeファイル(hspのインストーラーです)は失敗します。
不思議なことに、生成されたごみの頭2バイトは「MZ」なのですが……

enc.hsp

dialog "Choose any file which is wanted to encode.",0 dialog "*",16 _filepath =refstr if stat { //ファイルが選択された exist _filepath _filesize =strsize if _filesize <=0 or _filesize >2147483647/4{ dialog "An error has occured.\n\n* The file you have chosen is empty.\n* There is no file as you have chosen.\n* The file you have chosen is too big. (more than 512MB)\n\nWill now halt.\nErrCode: 1",1 end } sdim _filebuf,_filesize sdim _resp,_filesize*2 dim _etmp sdim _etmps bload _filepath,_filebuf repeat _filesize _etmp= peek(_filebuf,cnt) _etmps= strf("%02X",_etmp) _resp+=_etmps loop repeat strlen(_resp) _etmp= peek(_resp,cnt) switch _etmp case 'E' poke _resp,cnt,'*' swbreak case 'F' poke _resp,cnt,'#' swbreak swend loop notesel _resp dialog "txt",17,"Textfile" _safilepath =refstr if stat :else: dialog "No file has been set to save.\n\nWill now halt.\nErrCode: 2",1 notesave _safilepath end }else{ dialog "No file has been chosen.\n\nWill now halt.\nErrCode: 0",1 end } end

dec.hsp

dialog "Choose any file which is wanted to decode.",0 dialog "*",16 _filepath =refstr if stat { //ファイルが選択された exist _filepath _filesize =strsize if _filesize <=0 or _filesize >2147483647/2{ dialog "An error has occured.\n\n* The file you have chosen is empty.\n* There is no file as you have chosen.\n* The file you have chosen is too big. (more than 512MB)\n\nWill now halt.\nErrCode: 1",1 end } if _filesize\2!0 :dialog "The file you have chosen is not Collect Format File.\n\nWill now halt.\nErrCode: 3",1 :end sdim _filebuf,_filesize sdim _resp,_filesize/2 dim _etmp sdim _etmps bload _filepath,_filebuf repeat _filesize _etmp= peek(_filebuf,cnt) switch _etmp case '*' poke _filebuf,cnt,'E' swbreak case '#' poke _filebuf,cnt,'F' swbreak swend loop repeat _filesize/2 _etmp= peek(_filebuf,cnt*2) _etmps=strf("%c",_etmp) _etmp= peek(_filebuf,cnt*2+1) _etmps+=strf("%c",_etmp) poke _resp,cnt,int("$"+_etmps) loop notesel _resp dialog "*",17 _safilepath =refstr if stat :else: dialog "No file has been set to save.\n\nWill now halt.\nErrCode: 2",1 notesave _safilepath end }else{ dialog "No file has been chosen.\n\nWill now halt.\nErrCode: 0",1 end } end

ところで、0xと$は違うんですね。びっくりしました。



この記事に返信する


KA

リンク

2012/10/9(Tue) 20:39:44|NO.49891

質問するのは結構ですが、何をやっているのかを解析して、更にバグを見つけ
ろと言う事でしょうか。

せめて、何をやる目的で各部が何をやっているのかぐらいは説明して下さい。



Him

リンク

2012/10/9(Tue) 22:11:59|NO.49892

 
notesave _safilepath -> bsave _safilepath, _resp



F

リンク

2012/10/9(Tue) 22:23:31|NO.49893

できました!
Himさん、ありがとうございました!



ONION software Copyright 1997-2023(c) All rights reserved.