Lucas wrote:
> # How can I display a.jpg's binary code?
looks like you're confusing binary numbers with binary files:
http://en.wikipedia.org/wiki/Binary_numeral_system
http://en.wikipedia.org/wiki/Binary_file
you don't really need the former to encrypt the contents of the file;
algorithms ten
I am sorry my english is not good!
strList = ['1010010100','11101000100']
fileWrite = open('a.jpg','ab')
for item in strList:
fileWrite.write(item)
fileWrite.close()
# I don't know whether or not I succeed
fileRead = open('a.jpg','rb')
b = fileRead.read()
fileRead.close()
print b
#it is w
Lucas wrote:
> well, if I just open the file in binary mode, and write a string,e.g
> '660', how do i read the result? I means I need print the binary in
> screen.
I'm afraid that the more you write, the less sense you make.
> do these?
>
> fileWrite = open('a.jpg','ab')
> fileWrite.write('660
well, if I just open the file in binary mode, and write a string,e.g
'660', how do i read the result? I means I need print the binary in
screen.
do these?
fileWrite = open('a.jpg',''ab')
fileWrite.write('660')
fileWrite.close()
fileRead = open('a.jpg','rb')
b = fileRead.read()
fileRead.close()
Lucas wrote:
> I do it because I want to encrypt a string into a picture using RSA
> algorithm.
what does "into" mean? are you supposed to encrypt the binary data
representing the JPEG image, or embed a message into the actual image?
> so I first convert the string to binary,and then saving t
In <[EMAIL PROTECTED]>, Lucas wrote:
> thanks for your answer.
>
> I known how to do it.
> read() return a string. so
> 1) bytes = read(1) #read the file by bit.
This reads a byte, not a bit.
> 2) chrString = ord(bytes) #convert the string to ASCII.
Converts the byte into an integer with valu
22 Oct 2006 06:33:50 -0700, Lucas <[EMAIL PROTECTED]>:
I known how to do it.read() return a string. so1) bytes = read(1) #read the file by bit.2) chrString = ord(bytes) #convert the string to ASCII.3) print numberToBinary(chrString) #convert the ASCII to Binary using
my function.4) Loop[numberToBi
thanks for your answer.
I known how to do it.
read() return a string. so
1) bytes = read(1) #read the file by bit.
2) chrString = ord(bytes) #convert the string to ASCII.
3) print numberToBinary(chrString) #convert the ASCII to Binary using
my function.
4) Loop
I do it because I want to encrypt
In <[EMAIL PROTECTED]>, Lucas wrote:
> I need print a file in binary mode .
>
> f = f.open('python.jpg','rb')
> bytes = f.read()
> f.close()
>
> print(bytes)
>
> I can't get any binary code.
What do you mean by "binary code"? If you use ``print repr(bytes)``
everything outside ASCII will be p
I need print a file in binary mode .
f = f.open('python.jpg','rb')
bytes = f.read()
f.close()
print(bytes)
I can't get any binary code.
how to do it?
Thank you very much!
--
http://mail.python.org/mailman/listinfo/python-list
10 matches
Mail list logo