We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,608 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Convert python code to C# or vb.net

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.

2
Contributors
1
Reply
2 Hours
Discussion Span
5 Months Ago
Last Updated
4
Views
javi.crecenteespino
Newbie Poster
1 post since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

vegaseat
DaniWeb's Hypocrite
Moderator
6,499 posts since Oct 2004
Reputation Points: 1,451
Solved Threads: 1,618
Skill Endorsements: 37

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0640 seconds using 2.66MB