Author Topic: Binary files anyone?  (Read 136 times)

oradba4u

  • Jr. Member
  • **
  • Posts: 86
Binary files anyone?
« on: February 20, 2021, 08:23:08 am »
ALL:
I currently have an ASCII text file that I am using a WinBatch program to read/write. It contains sensitive information, and I'd like to know if there is a file format (like, binary?) that I can read/write that will replace the ASCII text file. I'm really not looking for encrypted top-secret kind of stuff, just something to keep looky-loo's from easily opening notepad to view it.

As always, thanks in advance

stanl

  • Pundit
  • *****
  • Posts: 1390
Re: Binary files anyone?
« Reply #1 on: February 20, 2021, 08:33:02 am »
Wow, more homework. Don't know if there is any 'top secret' stuff, but there are multiple ways to encrypt/decrypt in WB... think the Tech DB has a few. But, if you post the structure and some sample data you want encrypted, I'm sure you will get positive responses.


[EDIT]: probably base 64 will suit your needs


[EDIT 2]: actually I want Tony to come up with CLR code for : RijndaelManaged Class

oradba4u

  • Jr. Member
  • **
  • Posts: 86
Re: Binary files anyone?
« Reply #2 on: February 20, 2021, 08:42:25 am »
Data file is the same as the comma-delimited problem I was having a few days ago...

Here's a sample of what I've got:

Data file looks something like this:

Line 1 - Data File
1,2,3,4,5,6,7,8,9,10
2,3,4,,5,,6,7,,8,9,10,1
3,4,5,6,7,8,9,10,1,2
4,5,6,7,8,9,10,1,2,3
5,6,7,8,9,10,1,2,3,4
6,7,8,9,10,1,2,3,4,5

ChuckC

  • Sr. Member
  • ****
  • Posts: 289
Re: Binary files anyone?
« Reply #3 on: February 21, 2021, 05:17:18 am »
Use a technique such as ROT13 for basic obfuscation of text where you need to read & process the text on a per-character basis without having to convert the entire file to plaintext before working with it.  ROT13 has been around for a long time, with historical origins of the technique going back as far the Roman army using to protect written messages.

stanl

  • Pundit
  • *****
  • Posts: 1390
Re: Binary files anyone?
« Reply #4 on: February 21, 2021, 07:30:49 am »
thanks Chuck... pretty simple but can be made more complex
Code: Winbatch

text = "This is Test 5"
offset = 13
rot=""
;encrypt
For i = 1 To Strlen(text)
   char= StrSub(text,i,1)
   rot= rot:num2char(char2num(char)+13)
Next


Message(text,rot)


;decrypt
text=""
For i = 1 To Strlen(rot)
   char= StrSub(rot,i,1)
   text= text:num2char(char2num(char)-13)
Next


Message(rot,text)


 

ChuckC

  • Sr. Member
  • ****
  • Posts: 289
Re: Binary files anyone?
« Reply #5 on: February 21, 2021, 11:52:51 am »
Don't forget the modulo arithmetic for either unsigned 8 bit code points [ASCII/ANSI] or unsigned 16 bit code points.  Rollover above 255 or 65535 and underflow below zero must be accounted for if the rotated value is to be stored in the same byte or word in the file.

stanl

  • Pundit
  • *****
  • Posts: 1390
Re: Binary files anyone?
« Reply #6 on: February 21, 2021, 12:57:46 pm »
Don't forget the modulo arithmetic for either unsigned 8 bit code points [ASCII/ANSI] or unsigned 16 bit code points.  Rollover above 255 or 65535 and underflow below zero must be accounted for if the rotated value is to be stored in the same byte or word in the file.


I won't forget, but then it's not my thread :D

JTaylor

  • Pundit
  • *****
  • Posts: 1595
    • Data & Stuff Inc.
Re: Binary files anyone?
« Reply #7 on: February 21, 2021, 01:46:06 pm »
That goes without saying...how could anyone forget that?   ;)

ChuckC

  • Sr. Member
  • ****
  • Posts: 289
Re: Binary files anyone?
« Reply #8 on: February 21, 2021, 01:56:41 pm »
That should be easy enough to remember.... it's the two imaginary irrational cube roots of -1 that are more often not thought about...


stanl

  • Pundit
  • *****
  • Posts: 1390
Re: Binary files anyone?
« Reply #9 on: February 22, 2021, 02:36:20 am »
That should be easy enough to remember.... it's the two imaginary irrational cube roots of -1 that are more often not thought about...


which goes down easy after a 6-pack of Occam's Razor

stanl

  • Pundit
  • *****
  • Posts: 1390
Re: Binary files anyone?
« Reply #10 on: February 22, 2021, 07:59:04 am »
makes it a little trickier, if you remember the offset... [run several times for different results]
Code: Winbatch

text = "This is Test 5"
offset = Random((255 -122)/2)
rot=""
;encrypt
For i = 1 To Strlen(text)
   char= StrSub(text,i,1)
   rot= rot:num2char(char2num(char)+offset)
Next


Message(text,rot)


;decrypt
text=""
For i = 1 To Strlen(rot)
   char= StrSub(rot,i,1)
   text= text:num2char(char2num(char)-offset)
Next


Message(rot,text)