Subscribe

Hands on with Small Basic

or Encode and Decode messages to your friends!

Permalink by:Issac Kelly Sun Jan 11th, 2009 View Comments

Bookmark and Share

I started playing with small basic last night.

Turns out, it's a very good introduction to programming (I started with JavaScript, then C++, and this is much more simple/powerful in the early stages)
It's very similar in syntax to ASP or VB.

Since it's a variant of Basic, it has some things that I'm not a fan of (goto), but really, I won't hold that against it, goto makes sense in english, so it makes sense for a beginning language.

I took a few minutes and downloaded small basic, .Net 3.5 and the getting started guide from: http://msdn.microsoft.com/en-us/devlabs/cc950524.aspx

It was simple to setup, and the guide was definitely directed to the absolute beginer. *(sort of frustrating for their lack of documentation)

Here is my first small basic program:
It does trivial encoding and decoding.  Encode a message with a passcode, and send it to a friend, who can then decode it with the same passcode.
This is also a primer on how 'shared-key encryption' works.

 

start:
TextWindow.Write("(E)ncode or (D)ecode ")
a = TextWindow.Read()
If (a = "E") Then
    TextWindow.Write("String to Encode ")
    estring = TextWindow.Read()
    TextWindow.Write("Encryption Key ")
    password = TextWindow.Read()
    t = Network.GetWebPageContents("http://www.issackelly.com/string.php?action=encode&string="+estring+"&key="+password)  
    TextWindow.WriteLine(t)
    Goto start
Else
    If (a = "D") Then
    TextWindow.Write("String to Decode ")
    estring = TextWindow.Read()
    TextWindow.Write("Encryption Key ")
    password = TextWindow.Read()
    t = Network.GetWebPageContents("http://www.issackelly.com/string.php?action=decode&string="+estring+"&key="+password)  
    TextWindow.WriteLine(t)
    Goto start
    EndIf
EndIf

What you wil notice is Network.GetWebPageContents(....  I didn't actually do the encoding or decoding with small basic.  It lacked the basic math or character functions that I needed, so I had to fill in the gaps with PHP (I could have written an extension, but the documentation is too sparce)

So, here is my challenge.  Can you guess what I did to encrypt the string?

I'll give a free year of servee hosting and subscription to the first person who figures it out in the comments.

blog comments powered by Disqus

Site powered by Servee.