How to convert string "0671" or "0x45" into integer form with 0 and 0x in the beginning.

Posted by Harshit Sharma on Stack Overflow See other posts from Stack Overflow or by Harshit Sharma
Published on 2010-06-15T12:45:00Z Indexed on 2010/06/15 12:52 UTC
Read the original article Hit count: 251

Filed under:
|

I wanted to make my own encryption algorithm and decryption algorithm , encryption algorithm works fine and converts ascii value of the characters into alternate hexadecimal and octal representations. But when I tried decryption, problem occured as it return int('0671') = 671, as 0671 is string type in the following code. Is there a method to convert "ox56" into integer form??????

NOTE: Following string is alternate octal and hexa of ascii value of char.

///////////////DECRYPTION///////

l="01630x7401620x6901560x67"
f=len(l)
k=0
d=0
x=[]

for i in range(0,f,4):
  g=l[i:i+4]
  print g 
  k=k+1   
  if(k%2==0):
  p=g
  print p
  else:
  p=int(g)
  print p

© Stack Overflow or respective owner

Related posts about python

Related posts about octal