Home > Back-end >  Excuse me, how to convert JPG files to hex string!
Excuse me, how to convert JPG files to hex string!

Time:09-24

How do I transfer JPG ask hexadecimal string, regardless of the first converts it to BMP processing

CodePudding user response:

.

Procedure TForm1. Button1Click (Sender: TObject);
Var
MS: TMemoryStream;
SHex: string;
ISize: Integer;
The begin
MS:=TMemoryStream. Create;
Try
Ms. LoadFromFile (' c: \ 1. JPG);
ISize:=Ms. Size;
Ms. Position:=0;
SetLength (sHex, iSize * 2);
//sHex which stores is conversion results
BinToHex (PChar (Ms.) Memory, PChar (sHex), iSize);

MS. The Clear;
Ms. WriteBuffer (sHex [1], the length (sHex));
Ms. SaveToFile (' c: \ 1. TXT);
The finally
MS. The Free;
end;
end;

CodePudding user response:

reference 1st floor wdonghai response:
...

Procedure TForm1. Button1Click (Sender: TObject);
Var
MS: TMemoryStream;
SHex: string;
ISize: Integer;
The begin
MS:=TMemoryStream. Create;
Try
Ms. LoadFromFile (' c: \ 1. JPG);
ISize:=Ms. Size;
Ms. Position:=0;
SetLength (sHex, iSize * 2);
//sHex which stores is conversion results
BinToHex (PChar (Ms.) Memory, PChar (sHex), iSize);

MS. The Clear;
Ms. WriteBuffer (sHex [1], the length (sHex));
Ms. SaveToFile (' c: \ 1. TXT);
The finally
MS. The Free;
end;
end;

Support the 1st floor.

CodePudding user response:

It is ok to Base64 encryption
  • Related