掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
BlowFishで復号化のみするには? (ID:17012)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
こんな感じでどうでしょう function BFstr2File(key,Text,path:string; IV:Int64):boolean; var Crypt : TCryptCBC; Stream: TFileStream; Size,i :integer; dst : array of byte; begin result:=True; Crypt:= TCryptCBC.Create(Key, TBlowFish.Create, IV, SizeOf(IV), pmStandard); stream:= TFileStream.Create(path,fmCreate); try size := Length(Text); SetLength(dst, Crypt.OutputSize(Size)); Size := Crypt.Encode(Text[1], dst[0], Size); stream.Size:= size; stream.Seek(0,soFromBeginning); for i:=0 to size-1 do stream.Write(dst[i],1); finally stream.Free; Crypt.Free; end; end; function BFFile2str(key,path:string; IV:Int64):string; var Crypt : TCryptCBC; Stream:TFileStream; Size,size2,i :integer; dst,src : array of byte; begin stream:= TFileStream.Create(path,fmOpenRead ); Crypt:= TCryptCBC.Create(Key, TBlowFish.Create, IV, SizeOf(IV), pmStandard); try size:=stream.Size; stream.Seek(0,soFromBeginning); setLength(dst,size); for i:=0 to size-1 do stream.read(dst[i],1); size2 := Crypt.OutputSize(Size); SetLength(src,size2); size2 := Crypt.Decode(dst[0], src[0], Size); for i:=0 to size2-1 do result:= result + char(src[i]); finally stream.Free; Crypt.Free; end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.