Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 110 results for
binascii.hexlify
- Page 1
Re: Problem Returning MySQL Stored Procedure results using Python
Programming
Databases
2 Months Ago
by Dani
Haha, good job! Thanks for sharing your solution. Sometimes that happens with me. As you type it up, you think about how to phrase what's wrong and what needs to happen, and it makes you think about it from different angles, and you figure it out.
Reading a .raw file and display as hex
Programming
Software Development
6 Years Ago
by random_1
… to display in hex only. i sort of understand that
binascii
.
hexlify
() returns the hexadecimal representation of the binary data (.raw files… = open(fileName, "rb") byte = content.read(1) hexadecimal =
binascii
.
hexlify
(byte) self.file_content.setText(hexadecimal) I get : `TypeError: setText(self…
Re: Reading a .raw file and display as hex
Programming
Software Development
6 Years Ago
by Gribouillis
In python 3, the value returned by `
binascii
.
hexlify
()` is a `bytes` instance instead of a `str` instance. As `setText()` is expecting a `str` instance, you need to convert hexadecimal to `str`. This is done by hexa_str = hexadecimal.decode('utf-8')
Re: Reading a .raw file and display as hex
Programming
Software Development
6 Years Ago
by Gribouillis
…(fileName, "rb") as infile: content = infile.read() hex_bytes =
binascii
.
hexlify
(content) hex_str = hex_bytes.decode('utf-8') self.file_content.setText(hex_str)
Python CPU Performance Analysis
Programming
Software Development
9 Years Ago
by cjohnweb
….fcntl} 1 0.000 0.000 0.000 0.000 {
binascii
.a2b_hex} 509 0.014 0.000 0.014 0.000….getlower} 1 0.000 0.000 0.000 0.000 {
binascii
.
hexlify
} 404 11.793 0.029 11.793 0.029 {posix…
Re: Common File Types
Programming
Software Development
10 Years Ago
by Jade87
import sys, os,
binascii
def readfile(): dictionary = {'474946':(/>'GIF', 'gif'), '…\\'+ item, 'r') file_sig = file.read(3) file_sig_hex =
binascii
.
hexlify
(file_sig) if file_sig_hex in dictionary: print item + ' is a…
Common File Types
Programming
Software Development
10 Years Ago
by Jade87
…') file_sig = fh.read(4) print '[*] readFile() File:',filename #, 'Hash Sig:',
binascii
.
hexlify
(file_sig) def main(): if len(sys.argv) != 2: print 'usage…
Reading an entire binary file
Programming
Software Development
6 Years Ago
by nadiam
… the hexadecimal representation of the binary data, byte instance hexa =
binascii
.
hexlify
(data) with open("readprotrait1.raw", "wb"…
Re: Reading an entire binary file
Programming
Software Development
6 Years Ago
by Gribouillis
…: chunk = binaryfile.read(4096) if not chunk: break newFile.write(
binascii
.
hexlify
(chunk)) > my whole university life is on this (translation…
Re: Convert Bin to Hex
Programming
Software Development
13 Years Ago
by tcl76
… advice. final code is: [CODE] import
binascii
import string def byte_to_binary(n): return ''.join…return ''.join(byte_to_binary(ord(b)) for b in
binascii
.unhexlify(h)) ##def bintohex(s): ## return … in xrange(0, len(s), 8)) return
binascii
.
hexlify
(t) array0 = '000a00000003c0000030000c1f800000' print array0 a=…
Re: Convert Bin to Hex
Programming
Software Development
13 Years Ago
by Gribouillis
…],2)) for i in xrange(0, len(s), 8)) return
binascii
.
hexlify
(t) [/code] All of this would be easier with python…
Re: string.split problem
Programming
Software Development
14 Years Ago
by amadain
…8\4\5\6\7\10" print
binascii
.
hexlify
(foo) #5c30303850524f4d50545c303038003800380038003820637620003801025c38035c385c385c380405060708 print foo #\008PROMPT\0088888 …8\8 cleaned=foo.translate(norm,non_alnum) print
binascii
.
hexlify
(cleaned) #5c30303850524f4d50545c3030383838383820637620385c385c385c385c38 print cleaned #\008PROMPT\0088888 cv…
Re: Find, Copy, and Replace Strings in Python 3?
Programming
Software Development
13 Years Ago
by Beat_Slayer
…, 'rb') f_itl_bin = f_i.read() f_i.close() f_itl_hex = str(
binascii
.
hexlify
(f_itl_bin)).upper() results = f_itl_hex.find(old_key) if results != -1:…, 'rb') f_itl_bin = f_i.read() f_i.close() f_itl_hex = str(
binascii
.
hexlify
(f_itl_bin)).upper() f_itl_hex = f_itl_hex.replace(old_key, new_key.upper()) f_i =…
Re: String to Bits
Programming
Software Development
13 Years Ago
by Gribouillis
Here is a much faster version using
binascii
.
hexlify
: [code=python] from
binascii
import
hexlify
def a2bits(bytes): """Convert a sequence of bytes to its bits representation as a string of 0's and 1's This function needs python >= 2.6""" return bin(int(b"1" +
hexlify
(bytes), 16))[3:] [/code]
Re: Decoding binary file
Programming
Software Development
15 Years Ago
by mmeclimate
… example you can convert to readable hex format with [icode]
binascii
.
hexlify
[/icode]. I don't know if it's what you…'re looking for.[/QUOTE] But how would I use the
binascii
module to 'decode' my data, for example, if I wanted…
Re: Decoding binary file
Programming
Software Development
15 Years Ago
by Gribouillis
There are some conversion functions in the module [icode]
binascii
[/icode]. For example you can convert to readable hex format with [icode]
binascii
.
hexlify
[/icode]. I don't know if it's what you're looking for.
Re: Reading image as binary file
Programming
Software Development
15 Years Ago
by vegaseat
… of image file data # modified to work with Python30 import
binascii
try: # pick an image file you have in the working… of data to the corresponding 2-digit hexadecimal hex_str = str(
binascii
.
hexlify
(data)) # now create a list of 2-digit hexadecimals hex_list…
Re: Python List
Programming
Software Development
11 Years Ago
by deepthought
… how i passed the udp byte to the string:- import
binascii
mystring =
binascii
.
hexlify
(data) This resolved the problems and i got the…
using binascii
Programming
Software Development
15 Years Ago
by mruane
… at the document on python.org telling about
binascii
and a little bit about how to use…; for an NPC into pixel based graphics using
binascii
. I have the source code for PixelMan 3,…Cbrqvrtu8LwyzrunCqrq6rsuz7qizruq3rxnHrujB8pinLpqvqu
binascii
.a2b_base64(string) f = StringIO(sound_string) sound = pygame.mixer.Sound(f) sound.set_volume(…
Re: Reading a .raw file and display as hex
Programming
Software Development
6 Years Ago
by Gribouillis
… of the file # do something with the bytes read print(
hexlify
(data).decode('utf-8'))
Adding QThread in my code
Programming
Software Development
10 Years Ago
by mad5245
… abridged code: from PyQt4 import QtCore, QtGui import socket from
binascii
import
hexlify
import os import sys, string, telnetlib, time import csv…
Re: Calculate CRC32 checksums (like SFVs)
Programming
Software Development
14 Years Ago
by jlm699
… the file loaded into a string and then try print
binascii
.crc32(file-in-string) Still just gives me negative integers… 'rb', and [URL="http://docs.python.org/library/
binascii
.html#
binascii
.crc32"]RTFM[/URL] Use string formatting to print the…
Calculate CRC32 checksums (like SFVs)
Programming
Software Development
14 Years Ago
by dezza
… returns something like: -2087276233 [code]import
binascii
def getCRC(filename): filedata = open(filename).read() return
binascii
.crc32(filedata)[/code] Someone told me…
Re: Calculate CRC32 checksums (like SFVs)
Programming
Software Development
14 Years Ago
by dezza
[QUOTE=wildgoose;908609]Post your code! Check your variables are properly set signed/unsigned![/QUOTE] [code=python]import
binascii
def getCRC(filename): filedata = open(filename).read() return
binascii
.crc32(filedata)[/code]
Convert Bin to Hex
Programming
Software Development
13 Years Ago
by tcl76
… using Python 2.5 and Win XP. tq [CODE] import
binascii
import string def byte_to_binary(n): return ''.join(str((n &… hex_to_binary(h): return ''.join(byte_to_binary(ord(b)) for b in
binascii
.unhexlify(h)) def bintohex(s): return ''.join([ "%x"…
Problem python script
Programming
Software Development
12 Years Ago
by daggeras008
… any DATA="414e542d534541524348204d4441502f312e310d0a3436" #the Hello ID request import
binascii
SDATA =
binascii
.a2b_hex(DATA) #convert to ASCII ##[url]http://mail.python…
Re: Problem python script
Programming
Software Development
12 Years Ago
by TrustyTony
… socket import struct import sys import os import string import
binascii
#MADDX = '225.100.100.100' MADDX = '224.0.0.103… any DATA="414e542d534541524348204d4441502f312e310d0a3436" #the Hello ID request SDATA =
binascii
.a2b_hex(DATA) #convert to ASCII ##[url]http://mail.python.org…
pyinstaller 2.1 generated executable not running correctly
Programming
Software Development
9 Years Ago
by sbaw
… from C:\Python27\lib\__future__.pyc import math # builtin import
binascii
# builtin import _random # builtin # C:\Python27\lib\UserList.pyc matches….utils.versioninfo # cleanup[2] traceback # cleanup[2] weakref # cleanup[2]
binascii
# cleanup[2] ctypes # cleanup[2] xml.dom.xmlbuilder # cleanup[2…
Problem Returning MySQL Stored Procedure results using Python
Programming
Databases
3 Months Ago
by cored0mp
…; testing code. import psycopg2 from psycopg2 import Error import
binascii
from
binascii
import unhexlify import mysql.connector as mysql sql='''CREATE PROCEDURE…
Re: Calculate CRC32 checksums (like SFVs)
Programming
Software Development
14 Years Ago
by dezza
I have tried both open(filename, 'r') and open(filename, 'rb') I can get the file loaded into a string and then try print
binascii
.crc32(file-in-string) Still just gives me negative integers, what I want is the 8-char hexvalue.
1
2
3
Next
Last
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Meet People
Forums
Top Members
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC