Tag Archives: Visual Studio 2010

Essential Functions: getLocalIp() and ByteArToHex()

That I don’t want to re-write in case my hard drive breaks, all public domain:

Private Function getLocalIp() As String

        Dim myips As Net.IPHostEntry = System.Net.Dns.GetHostEntry(Net.Dns.GetHostName)

        Dim myip As String = “127.0.0.1”

        For Each ipaddress As Net.IPAddress In myips.AddressList
            If ipaddress.ToString.Split(“.”).Count = 4 Then
                If ipaddress.ToString <> “127.0.0.1” Then
                    myip = ipaddress.ToString
                    Exit For
                End If
            End If
        Next

        Return myip

    End Function

 


 

    Private Function ByteArToHex(ByVal byteAr As Byte())
        Dim s1 As String = “”
        For Each c1 As Byte In byteAr
            s1 = s1 + String.Format(“{0:X2}”, c1)

        Next
        Return s1

    End Function

 


 

Leave a comment

Filed under Uncategorized

Possible bugs in Visual Studio 2010 and WordPress

On wordpress first:
I get followers and likes even though I have no views during the day and block viewers from reading the whole text on “reader”

On visual studio:
If one creates a raw socket, it doesn’t receive data from tcp/udp requests(neither from visual studio nor firefox)
If you create a non-blocking udp server, and try to modify a control without invoke the program simply closes without raising errors(It didn’t happen with the asynchronous tcp server I built yesterday)
About raw sockets again, it says on the tooltip that you need to create your own ip header, in practice it sends the header by itself.

Leave a comment

Filed under Uncategorized

Cryptography #2

So, it turns out I couldn’t generate public keys from private ones using Diffie-Hellman algorithm, it took several minutes for even a limited size private key.

In the end I went back to visual basic and after lots of researching(thanks stackoverflow) I got a handle on how to extract(export) private and public keys.
That may be unnecessary though, I can simply send a signature with the algorithm I’m using(one called “ECDsa”). If I were to save the private key I’d need to authorize it at object(Security.Cryptography.CngKey) instantiation.

EDIT:
I need to send the public key even if I have a signature. No idea why I said I didn’t need to. I spent most of the previous days trying to accomplish just that.

Leave a comment

Filed under Uncategorized

Cryptography

Asides from GUI this seems to be the second major weakness in python. No public/private key generator. To make things worse, visual studio documentation doesn’t seem simple either. It has all stuff I probably need but it’s confusing. Does CngKey refers to a public or private key? And how do I store it in a plain text file?

Here is what I really needed:

getPrivateKey()
Gets a new private key that is random/prime/secure/etc

getPublicKey(privateKey)
Gets the matching public key

getSharedSecret(privateKey,friendPublicKey)
Gets a shared secret(that I’ll use in a keyed hash, like hmac)

Done. I could implement that in Python but I am 99% sure I would make a serious mistake and expose the private key.

I don’t want a certificate or to associate either key or the shared secret with any company or person. Just to have that link between private and public key.

Leave a comment

Filed under Uncategorized

P2P in Visual Studio 2010

I was having trouble making my server/client(it is going to be a node) communicate with firefox(for purposes of testing), I wasted some time learning what “hole punching” is and even thought I was going to have an uphill battle with this issue. Alas, VB has a TcpListener with the following function: AllowNatTraversal. All you need to do is to bind your external IP address on your TcpListener and then call AllowNatTraversal(True). Done. You can now receive stuff from the client 😀

Thank you Bill Gates.

Now, on a side note, how do they do it? Last time I checked “hole punching” required a non-firewalled server and didn’t work very well trough TCP. Hmmmm. Perhaps some other method of NAT traversing? I hope I’m not building something that will rely on a centralized server. It would kill the point of having P2P.

Leave a comment

Filed under Uncategorized

Whoa, “new” components!

Great tip for you if you are using Visual Studio 2010, right click the component toolbox and click “Choose items”

Leave a comment

Filed under Uncategorized