HTML decrypter, In QBasic!!

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

HTML decrypter, In QBasic!!

Post by Rattrapmax6 »

:) Yay, I've had the bright Idea to make a HTML decrypter. Its not much now, but its somthing I'm playing around with for fun.. take a look...
(Reads TXT & HTM, but fails to read HTML dubbed files)

Code: Select all

DECLARE SUB PARAread ()
DECLARE SUB BODYRead ()
DECLARE SUB HEADRead ()
DECLARE SUB TTLPRT ()
DECLARE SUB Overflow ()
DECLARE SUB TAGCheck ()
DECLARE SUB OpenHTML ()
DECLARE SUB HTMLread ()
DECLARE SUB HTMLCheck ()
DIM SHARED html$, cont, htm$, para$, header$, html2$
CLS
INPUT "Enter .HTM Document:", htm$
CLS
CALL HTMLCheck
CALL OpenHTML
CALL TAGCheck
cont = 0
CALL HTMLread
PRINT cont

SUB BODYRead
DO
cont = cont + 1
IF cont = LEN(html$) THEN END
IF MID$(UCASE$(html$), cont, 3) = "<P>" THEN cont = cont + 2: CALL PARAread
LOOP
END SUB

SUB HEADRead
DO
cont = cont + 1
IF cont = LEN(html$) THEN END
IF MID$(UCASE$(html$), cont, 7) = "<TITLE>" THEN cont = cont + 6: CALL TTLPRT
LOOP
END SUB

SUB HTMLCheck
cont = 0
DO
cont = cont + 1
IF cont = LEN(htm$) THEN PRINT " Not .HTM/.TXT Document ": END
IF MID$(UCASE$(htm$), cont, 3) = "TXT" THEN EXIT DO
IF MID$(UCASE$(htm$), cont, 3) = "HTM" THEN EXIT DO
LOOP

END SUB

SUB HTMLread
DO
cont = cont + 1
IF cont = LEN(html$) THEN END
IF MID$(UCASE$(html$), cont, 6) = "<HEAD>" THEN CALL HEADRead
IF MID$(UCASE$(html$), cont, 6) = "<BODY>" THEN CALL BODYRead
IF MID$(UCASE$(html$), cont, 7) = "</HTML>" THEN END
LOOP
END SUB

SUB OpenHTML
OPEN htm$ FOR INPUT AS #1
DO
IF EOF(1) = -1 THEN EXIT DO
LINE INPUT #1, a$
html$ = html$ + a$
IF LEN(html$) = 199 THEN PRINT " File To Big! ": END
LOOP
CLOSE #1
END SUB

SUB PARAread
DO
cont = cont + 1
IF cont = LEN(html$) THEN END
IF MID$(UCASE$(html$), cont, 4) = "</P>" THEN EXIT DO
phs$ = phs$ + MID$(html$, cont, 1)
LOOP
PRINT
PRINT phs$
CALL HTMLread
END SUB

SUB TAGCheck
cont = 0
DO
cont = cont + 1
IF cont = LEN(html$) THEN PRINT " No <html> tag located ": END
IF MID$(UCASE$(html$), cont, 6) = "<HTML>" THEN EXIT DO
LOOP
END SUB

SUB TTLPRT
DO
cont = cont + 1
IF cont = LEN(html$) THEN END
IF MID$(UCASE$(html$), cont, 8) = "</TITLE>" THEN EXIT DO
ttl$ = ttl$ + MID$(html$, cont, 1)
LOOP
PRINT ttl$
PRINT
CALL HTMLread
END SUB
Text File or HTM file...

Code: Select all

<HTML>
<HEAD>
<TITLE>QB HTML READER!</TITLE>
</HEAD>
<BODY>
<P>This is a HTML paragraph being read by QBasic Yay!!</P>
</BODY>
</HTML>
It is limited to <html>, <head>, <body>, <p>, <title>, and their reverse tags.. Also sofar the file has to be less than 199 charaters.. :D This is just a decrypter for now, not a veiwer, so no mouse function is present.

Note: If you also like to mess around and improve on it, its a great introduction to using the MID$() statment for scanning files for infomation, feel free to do so.. :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows »

Not a bad first attempt at all Kevin. looks well made :-)
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:) Yeah, its just a siple code now,. I was looking back over it and saw that it only read one <P> tag,. but that can be fixxed by chaning the "CALL HTMLread" to "CALL BODYread" at the PARAread SUB,..

But like you said it a first attemp, heh heh,. your not going to get two <P>s in a 199 char limit decypter that say much.. :wink: Thanks...
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

I agree with MystikShadows.
I also agree with Rattrap.

heh...I'm just agreeing with everybody lol :lol:

Ya with that 2 Gig String thing in FB you should redo it in it....Yep
Also HTML is has a lot to it....just be glad your not doing Javascript also....*Mit shudders*....
:D
"But...It was so beutifully done"
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

JAVASCRIPT! AHH! *starts screaming like Homer Simpson and running around in circles* AHH! AHH! AHH!
:roll:
Image
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:D Ha ha, Mitth, you sound like a regular FBer now.. :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Really and all I did was see how pretty their site was....hmmm...

I haven't even touched a download yet....
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:) Bookmark this site for when you go to download, like I said b4, I realy think this is a cool FBIDE and compiler package, :wink:

http://www.hot.ee/fbide/

Check out the screens for it,. :)
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Thanks! :D
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Okay, QB is not limited to 200 chars to straing$, it will hold 32767 chars.. Here I've modified to program to read it.. It also can read more that one <P> tag.. :wink:

Its at its best at the moment,. anymore and I'll have to convert to gfx texts to display <Hx> tags,. Its just a small decrypter still, and I don't plan to make it a viewer any time soon..

Code: Select all

DECLARE SUB PARAread ()
DECLARE SUB BODYread ()
DECLARE SUB HEADRead ()
DECLARE SUB TTLPRT ()
DECLARE SUB TAGCheck ()
DECLARE SUB OpenHTML ()
DECLARE SUB HTMLread ()
DECLARE SUB HTMLCheck ()
DIM SHARED html$, cont, htm$, para$, header$, html2$
CLS
INPUT "Enter .HTM/.TXT Document:", htm$
CLS
CALL HTMLCheck
CALL OpenHTML
CALL TAGCheck
cont = 0
CALL HTMLread
PRINT cont

SUB BODYread
DO
cont = cont + 1
IF cont = LEN(html$) THEN END
IF MID$(UCASE$(html$), cont, 3) = "<P>" THEN cont = cont + 2: CALL PARAread
LOOP
END SUB

SUB HEADRead
DO
cont = cont + 1
IF cont = LEN(html$) THEN END
IF MID$(UCASE$(html$), cont, 7) = "<TITLE>" THEN cont = cont + 6: CALL TTLPRT
LOOP
END SUB

SUB HTMLCheck
cont = 0
DO
cont = cont + 1
IF cont = LEN(htm$) THEN PRINT " Not .HTM/.TXT Document ": END
IF MID$(UCASE$(htm$), cont, 3) = "TXT" THEN EXIT DO
IF MID$(UCASE$(htm$), cont, 3) = "HTM" THEN EXIT DO
LOOP

END SUB

SUB HTMLread
DO
cont = cont + 1
IF cont = LEN(html$) THEN END
IF MID$(UCASE$(html$), cont, 6) = "<HEAD>" THEN CALL HEADRead
IF MID$(UCASE$(html$), cont, 5) = "<BODY" THEN CALL BODYread
IF MID$(UCASE$(html$), cont, 7) = "</HTML>" THEN END
LOOP
END SUB

SUB OpenHTML
OPEN htm$ FOR INPUT AS #1
DO
IF EOF(1) = -1 THEN EXIT DO
LINE INPUT #1, a$
html$ = html$ + a$
IF LEN(html$) = 32767 THEN PRINT " File To Big! ": END
LOOP
CLOSE #1
END SUB

SUB PARAread
DO
cont = cont + 1
IF cont = LEN(html$) THEN END
IF MID$(UCASE$(html$), cont, 4) = "</P>" THEN EXIT DO
phs$ = phs$ + MID$(html$, cont, 1)
LOOP
PRINT
PRINT phs$
CALL BODYread
END SUB

SUB TAGCheck
cont = 0
DO
cont = cont + 1
IF cont = LEN(html$) THEN PRINT " No <html> tag located ": END
IF MID$(UCASE$(html$), cont, 6) = "<HTML>" THEN EXIT DO
LOOP
END SUB

SUB TTLPRT
DO
cont = cont + 1
IF cont = LEN(html$) THEN END
IF MID$(UCASE$(html$), cont, 8) = "</TITLE>" THEN EXIT DO
ttl$ = ttl$ + MID$(html$, cont, 1)
LOOP
PRINT ttl$
PRINT
CALL HTMLread
END SUB
Text Document. or HTM Document.

Code: Select all

<HTML>
<HEAD>
<TITLE>QB HTML READER!</TITLE>
</HEAD>
<BODY>
<P>This is a HTML paragraph being read by QBasic, Yay!!</P>
<P>This is the second paragraph in QB!!</P>
<P>What the heck lets go for THREE!!</P>
<P>Stressing the string$ size it holds up 32767 chars 
for reading most HTML code as it is doing now! 
Enjoy this program. Its great for those who would 
like to learn how to use MID$() to scan files!</P>
</BODY>
</HTML>
Well there it is,.. Like I said befor, anyone interested in using the MID$() to read and sort information, this is a good example I think... And also any who like the idea can improve on it... :)

This is still limited to <html>, <head>, <body>, <title>, <p>, and their reverse tags.. but I moved the chars size up.. :wink: and if you havn't noticed, this reads more than one <P>,.. Its also case insesitive, so you can use <HTML>, <HtMl>, or <html> and it still work. :D
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Hey Ummm....why did you want to do this anyway?

Ya I guess I was wrong but still.... :(
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:) , Nah, we all make mistakes, :wink:

Just for fun really, see if it really work.. it does so I'm happy.. :D
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Ya ok,

You know if Nathen got back to us on that parser thing yet? :?
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Umm, no, but he posted above,. :wink: ,. I think he got our finished debbug, he said something bout a tutorial for it sometime back.. :)
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Oh, yeah that's right, I remember wondering why he was asking to do a tut on something he didn't know how to do....oh well :roll:
"But...It was so beutifully done"
Post Reply