Home > Software engineering >  Using VB to do EXE runtime needs to read a text file, how to encrypt the TXT?
Using VB to do EXE runtime needs to read a text file, how to encrypt the TXT?

Time:09-23

With the VB do runtime needs to read a text file, how to encrypt the TXT text file?
You could change the text file TXT together generated EXE ?

That there are about 1000 lines of text files, in both English and Chinese, Chinese can also be deleted,

CodePudding user response:

Can take them to the resources...

CodePudding user response:

reference 1st floor Topc008 response:
can take them to the resources...


How to put?
My file is more, more than 1000 lines, not one line of stickup go up? Can you say in detail? thank you

CodePudding user response:

refer to the second floor HNRXRN response:
Quote: refer to 1st floor Topc008 response:

Can take them to the resources...


How to put?
My file is more, more than 1000 lines, not one line of stickup go up? Can you say in detail? Thank you

Is "a file to add a file",


CodePudding user response:

After joining the first resource identification number is 101, the type of "CUSTOM resources" is the CUSTOM,
You can double-click on it in the "id", change its identification number, such as the 101 to 1001, or the ABCD case-insensitive (letter), such as
Type is best not to change! "Language" without change, generally no actual meaning,
After add good resources, click on the "disk" icon, save resources,
Program is running, use LoadResData () function to read,
 Dim aBuff () As Byte 

ABuff=LoadResData (" ABCD ", "CUSTOM")



CodePudding user response:

Encryption... To who?
"File is more, more than 1000 lines,"
The custom file structure,
That you must be a TXT
Add resources, is a way to add a custom file structure.

CodePudding user response:

Advise the landlord don't spend and waste your limited life infinite encryption to decrypt dead loop!

CodePudding user response:

reference 4 floor Chen8013 response:
after joining, the first resource identification number is 101, the type of "CUSTOM resources" is the CUSTOM,
You can double-click on it in the "id", change its identification number, such as the 101 to 1001, or the ABCD case-insensitive (letter), such as
Type is best not to change! "Language" without change, generally no actual meaning,
After add good resources, click on the "disk" icon, save resources,
Program is running, use LoadResData () function to read,
 Dim aBuff () As Byte 

ABuff=LoadResData (" ABCD ", "CUSTOM")

You too hard, thank you very much,
My file content is a large amount of data, the original is copy of data in a CSV file into TXT, then the TXT import resources, but how to specify the location of the data read,
Use your method to print out all of the data, changing abuff [0) can only display data in 255, specify the location of the data is how to extract it? Thank you very much


Private Sub Command1_Click ()
Dim abuff () As Byte
Abuff=LoadResData (101, "custom")
Print abuff (0)
End Sub







CodePudding user response:

Now that is a fixed format of the data, use the code first convert CSV to custom binary dat file,
Exe read the dat file, need not TXT file,

CodePudding user response:

refer to the eighth floor Tiger_Zhao response:
since be fixed format of the data, use the code first convert CSV to custom binary dat file,
Exe read the dat file, don't TXT file.


Thank you, can give me a tutorial? Access to the specified location data

CodePudding user response:

Abuff (0)=255? Is the "text" of your BOM head with utf-8 encoded files!
Print abuff (0) just to make the "file 1 byte code value in the" output, according to the decimal value is not a "text",

To say "no" of encryption:
You press the "ANSI" save file format code, then join the resources in the way I said to you,
In LoadResData (), perform:
Print strconv (abuff vbUnicode)
To "restore the text content,"
You can help yourself to the first one only a few characters of a text file try effect,

Say "encryption" :
You press the "ANSI" save file format code, then the "clear" text file encryption for new files, such as call: Encrypt. Dat
To Encrypt. Dat according to custom resources in engineering,
In performing abuff=LoadResData (101, "custom"), after abuff () is encrypted data;
What is needed is for abuff () the content of "decryption" (how to encrypt, decrypt, decide on your own, of course must be "reversible encryption algorithm"),
Such as the "decrypt data output to another string array aBuff2 (),
At this time, with a string variable: strText=strconv (aBuff2 vbUnicode)
The contents of the strText is your original "clear text",

Say "encoding" problem, VB6 string "stored in memory", is a Unicode format (UTF - 16) coding,
Strconv () function, support the ANS with utf-8 format conversion between 16,
If you want to use other coding format, you need to use API function transform,
These two functions is main: MultiByteToWideChar (), WideCharToMultiByte ()
Yours is utf-8, for example, it can be used into UTF - 16, you can search for specific usage information,
Note that if you file data "BOM head", the two API calls the above, is to remove the BOM header data, coding format is to use parameters specified,

But since you are written in VB6 program, it is suggested that the encoding of a text file or use the ANSI format is more convenient (unless you have the ANSI format cannot be said of characters),
  • Related