Hi there, I need some help to finish that code, In fact, there is one problem in my code : The last line, when i tried to convert a hexadecimal number in int. The problem is, I got variables containing : ff or 00 or C6 etc... And i want to add "0x" at the begining, for that, I added as string, but when i tried to convert in int, this doesn't work, and it said :

----- File "Stegano Real.py", line 138, in <module>
r3.append(int(i))
ValueError: invalid literal for int() with base 10: 'oxff' ----

Here it's my code :

``````import PIL.Image
from tkinter import *
import os

im1 = PIL.Image.open('header.png') # Ouverture de l'Image à cacher 1
im1.putalpha(0)  # Insertion du canal Alpha (transparance)
px1 = list(im1.getdata()) # Insère dans la liste le RGBA de tt les pixels.

r1 = [] # Création des listes RGBA
g1 = []
b1 = []
a1 = []

for i in px1 :  # Affectation des valeurs aux listes respectives.
list(i)
r1.append(i[0])
g1.append(i[1])
b1.append(i[2])
a1.append(i[3])

rhex1 =[]  # Création des liste pour les haxadécimales
ghex1 = []
bhex1 = []
ahex1 = []

for i in r1 : # Hexadécimalage des listes.
rhex1.append(hex(i))
for i in g1 :
ghex1.append(hex(i))
for i in b1 :
bhex1.append(hex(i))
for i in a1 :
ahex1.append(hex(i))

rhex1fort = []  # Création des listes pour les hexa fort (1er)
ghex1fort = []
bhex1fort = []
ahex1fort = []

for i in rhex1 :
rhex1fort.append(i[2])
for i in ghex1 :
ghex1fort.append(i[2])
for i in bhex1 :
bhex1fort.append(i[2])
for i in ahex1 :
ahex1fort.append(i[2])
# -------------------------------------------------------

im2 = PIL.Image.open('header2.png') # Ouverture de l'Image
im2.putalpha(0)  # Insertion du canal Alpha (transparance)
px2 = list(im2.getdata()) # Insère dans la liste le RGBA de tt les pixels.

r2 = [] # Création des listes RGBA
g2 = []
b2 = []
a2 = []

for i in px2 :  # Affectation des valeurs aux listes respectives.
list(i)
r2.append(i[0])
g2.append(i[1])
b2.append(i[2])
a2.append(i[3])

rhex2 =[]  # Création des liste pour les haxadécimales
ghex2 = []
bhex2 = []
ahex2 = []

for i in r2 : # Hexadécimalage des listes.
rhex2.append(hex(i))
for i in g2 :
ghex2.append(hex(i))
for i in b2 :
bhex2.append(hex(i))
for i in a2 :
ahex2.append(hex(i))

rhex2fort = []  # Création des listes pour les hexa fort (1er)
ghex2fort = []
bhex2fort = []
ahex2fort = []

for i in rhex2 :            # Récupération des bytes forts de la 2eme im
rhex2fort.append(i[2])
for i in ghex2 :
ghex2fort.append(i[2])
for i in bhex2 :
bhex2fort.append(i[2])
for i in ahex2 :
ahex2fort.append(i[2])

# mettre le bytes fort 2 en bytes faible dans la liste.

rhex3 = []
ghex3 = []
bhex3 = []
ahex3 = []

s=0
for i in rhex2 :
rhex3.append("ox"+rhex1fort[s]+rhex2fort[s])
s=s+1
s=0
for i in bhex2 :
bhex3.append("ox"+bhex1fort[s]+bhex2fort[s])
s=s+1
s=0
for i in bhex2 :
bhex3.append("ox"+bhex1fort[s]+bhex2fort[s])
s=s+1
s=0
for i in bhex2 :
bhex3.append("ox"+bhex1fort[s]+bhex2fort[s])
s=s+1

r3 =[]
g3 = []
b3 = []
a3 = []

for i in rhex3 :
r3.append(int(i))
for i in ghex3 :
g3.append(int(i))
for i in bhex3 :
b3.append(int(i))
for i in ahex3 :
a3.append(int(i))

print(bhex2)
``````

Check line by line error and check and brif expalain on query or suggestions .

I already do that, else I didn't post here..
But, my real problem is, imagine this code :

``````a = "0x" + "ff" # So a = "0xff"
# and i want to have a = 0xff
# Because I want to do int(a)to have 255.
``````

Try `int('ff', base=16)`

edit:
also have a look at standard modules binascii and array.

I want to kiss you on your mouth ! I love you ! Kingman ! <3 <3 <3

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.