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()
print b
???????
Thanks again
Fredrik Lundh wrote:
> 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 the binary
> > into picture
>> you seem to have a rather fuzzy understanding of the words "string" and
> "binary" here. if you read from a file that's opened in binary mode,
> you get an 8-bit string that contains the binary data. there's no need
> for any conversion here; just use the data you got from "read".
>> > finally, print the picture by binary!
>> do you mean "save the picture to a binary file", or something else?
>> </F>