Ooops
November 25, 2020, 08:21:59 AM

Author Topic: [bb] bin2asc by Techlord [ 1+ years ago ]  (Read 619 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] bin2asc by Techlord [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : bin2asc
Author : Techlord
Posted : 1+ years ago

Description : Binary To Ascii, Ascii To Binary Converters

This is a very simple utility that converts ascii to binary visa versa. This can be useful for converting binary files and posting the ascii version in forums, etc. I',m sure that others can devise a more complex bin2asc encoder/decoder.

Have Fun!


Code :
Code: BlitzBasic
  1. ;BINARY 2 ASCII
  2. filename$=Input("Input Filename:")
  3. filename2$=input("Output Filename:")
  4. file=ReadFile(filename$)
  5. If file
  6.         file2=WriteFile(filename2$)
  7.         While Not Eof(file)
  8.                 WriteLine(file2,ReadByte(file))
  9.         Wend
  10.         CloseFile(file2)
  11.         CloseFile(file)
  12. EndIf
  13.  
  14. ;ASCII 2 BINARY
  15. filename$=Input("Filename:")
  16. filename2$=input("Output Filename:"


Comments :


RRK1020(Posted 1+ years ago)

 dats alotta numbers...


RRK1020(Posted 1+ years ago)

 I made duality from slipknot to see if it works. It works fine.


XtremeCoder(Posted 1+ years ago)

 Function format...;BINARY 2 ASCIIfilename$=Input("Input Filename:")filename2$=Input("Output Filename:")BIN2ASC(filename$,filename2$)Function BIN2ASC(filename$,filename2$)file=ReadFile(filename$)If file   file2=WriteFile(filename2$)   While Not Eof(file)      WriteLine(file2,ReadByte(file))   Wend   CloseFile(file2)   CloseFile(file)EndIf End Function;ASCII 2 BINARYfilename$=Input("Filename:")filename2$=Input("Output Filename:")ASC2BIN(filename$,filename2$)Function ASC2BIN(filename$,filename2$)file=ReadFile(filename$)If file   file2=WriteFile(filename2$)   While Not Eof(file)      WriteByte(file2,ReadLine(file))   Wend   CloseFile(file2)   CloseFile(file)EndIfEnd Function


CS_TBL(Posted 1+ years ago)

 1337 format... (no ultra-long page o' numbers)
Code: [Select]
s$=Bin2String("<yourfile.ext>",64)

Showtext s$,1024,768

String2Bin s$,"<yournewfile.ext>"

Notify "o_O"

End

Function Showtext(t$,w=640,h=480)
cw=ClientWidth(Desktop())
ch=ClientHeight(Desktop())
If w<1 Or h<1
w=cw:h=ch
EndIf
If w>cw w=cw
If h>ch h=ch
window=CreateWindow("Show text",cw/2-w/2,ch/2-h/2,w,h,0,3)
textarea=CreateTextArea(0,0,ClientWidth(window),ClientHeight(window),window)
SetTextAreaColor textarea,128,192,255
SetTextAreaColor textarea,0,32,64,1
SetTextAreaText textarea,t$
Repeat
WaitEvent()
If EventSource()=window
If EventID()=$803 Exit
If EventID()=$802
SetGadgetShape textarea,0,0,ClientWidth(window),ClientHeight(window)
EndIf
EndIf
Forever
FreeGadget window
End Function

Function Bin2String$(file$,w=32) ; w = width of each line
If file$="" Return
filein=OpenFile(file$)
If filein
size=FileSize(file$)
x=0
For t=0 To size-1
b=ReadByte(filein)
bhigh=(b /16) ; be high,
blow=(b And 15) ; and blow :D
s$=s$+Chr$(65+bhigh)+Chr$(65+blow)
x=x+1
If x>=w
x=0:s$=s$+Chr$(13)+Chr$(10)
EndIf
Next
CloseFile filein
Else
s$="<error>"
EndIf
Return s$
End Function

Function String2Bin(s$,file$)
If s$="" Return
If file$="" Return
fileout=WriteFile(file$)
If fileout
s$=Replace(Replace(s$,Chr(10),""),Chr(13),"")
size=Len(s$)/2
For t=0 To size-1
bhigh=(Asc(Mid(s$,1+t*2+0,1))-65)*16 ; yeayea :D
blow=Asc(Mid(s$,1+t*2+1,1))-65 ; o_O
WriteByte fileout,bhigh+blow
Next
CloseFile fileout
Else
RuntimeError "file error"
EndIf
End Function


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal