Hello people. Sorry for my English, I use google translator ..

Please Can anyone convert this code to C # or vb.net?

import sys   

VERSION    = 0
SUBVERSION = 2  

def usage():  
print "[+] WPSpin %d.%d " % (VERSION, SUBVERSION)     
print "[*] Usage : python WPSpin.py 123456" 
sys.exit(0)   

def wps_pin_checksum(pin):     
accum = 0    

while(pin):         
accum += 3 * (pin % 10)         
pin /= 10        
accum += pin % 10        
pin /= 10    

return  (10 - accum % 10) % 10  

try:     

if (len(sys.argv[1]) == 6):         
p = int(sys.argv[1] , 16) % 10000000        
print "[+] WPS pin is : %07d%d" % (p, wps_pin_checksum(p))     
else:         
usage() 
except Exception:     
usage()

Thank you very much.

Recommended Answers

All 3 Replies

Play around with this, it might give you enough hints:
http://www.developerfusion.com/tools/convert/csharp-to-python/

Good advice:
http://stackoverflow.com/questions/683273/advice-for-c-sharp-programmer-writing-python

There is also IronPython (MS endorsed) with a Python syntax that can be called from C# (4.0):
http://blogs.msdn.com/b/charlie/archive/2009/10/25/hosting-ironpython-in-a-c-4-0-program.aspx

Thank you for welcoming me, Dani.
I want to ask is it a suitable website to convert my VB code to python code?

commented: Please don't bury your new questions like this. +15

Sure is, just hit the contribute button and make sure to ask your question in the most appropriate section (programming | software dev) - good luck fella!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.