3 Replies - 794 Views - Last Post: 10 March 2014 - 10:30 PM Rate Topic: -----

#1 javey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-February 14

Convert ascii file to hex

Posted 18 February 2014 - 11:22 PM

I have a wordlist I'm trying to convert to ascii...my script is working for converting, but instead of putting line breaks between every word it's simply putting all the words together. Why is it doing that and how can I fix it? I need it formatted the same like the source file. Here's what I have for a script...

import binascii
filename = 'c:/Python33/wordlist1.txt'
with open(filename, 'rb') as f:
    content = f.read()
out = binascii.hexlify(content)

f = open('out.txt', 'wb')
f.write(out)
f.close()

import binascii
filename = 'out.txt'
with open(filename, 'rb') as f:
    content = f.read()
asci = content.decode("hex")

asci = out.decode("hex")
w = open('printed.txt', 'wb')
w.write(asci)
w.close()


This is not for a homework or anything but rather to make a dictionary wordlist.

Thanks in advance,

J

Is This A Good Question/Topic? 0
  • +

Replies To: Convert ascii file to hex

#2 javey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-February 14

Re: Convert ascii file to hex

Posted 20 February 2014 - 08:27 PM

Any ideas?
Was This Post Helpful? 0
  • +
  • -

#3 woooee  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 109
  • Joined: 21-November 12

Re: Convert ascii file to hex

Posted 25 February 2014 - 02:16 PM

You are converting spaces and newlines as well. Split the read, using readlines and then strip and split each line on the space, unless each line is one word, then the split isn't necessary. Write each line individually and append a newline and you should be good to go.
Was This Post Helpful? 0
  • +
  • -

#4 javey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-February 14

Re: Convert ascii file to hex

Posted 10 March 2014 - 10:30 PM

View Postwoooee, on 25 February 2014 - 02:16 PM, said:

You are converting spaces and newlines as well. Split the read, using readlines and then strip and split each line on the space, unless each line is one word, then the split isn't necessary. Write each line individually and append a newline and you should be good to go.


Huh? I'm not quite understanding.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1