Thank you for your reply, my bad, after your post and 2h of try i have found my problem, it's not the AES api my problem it's just a big noob error :
(the trace script dont really help me because i don't return my problem, but after 150 "monitor.write" line per line i found it :D/>)
Client :
-- CLIENT
-- plug monitor
local monitor = peripheral.find("monitor", function(name, object) object.side = name return true end)
-- plug modem
local modem = peripheral.find( "modem", function( name, obj ) return obj.isWireless() end)
local password = "1234"
os.loadAPI("system/api/AES")
os.loadAPI("system/api/base64")
while true do
write("send : ")
msg= read()
msg = AES.encrypt(password, msg)
msg = base64.encode(msg)
modem.transmit(3, 1, msg)
end
Server :
-- SERVER1
-- plug monitor
local monitor = peripheral.find("monitor", function(name, object) object.side = name return true end)
-- plug modem
local modem = peripheral.find( "modem", function( name, obj ) return obj.isWireless() end)
local password = "imabadpwd"
os.loadAPI("system/api/AES")
os.loadAPI("system/api/base64")
function newLine()
local _,cY= monitor.getCursorPos()
monitor.setCursorPos(1,cY+1)
end
function monclear()
monitor.clear()
monitor.setCursorPos(1,1)
end
while true do
modem.open(3)
local event, modemSide, senderChannel,
replyChannel, msg, senderDistance = os.pullEventRaw("modem_message")
monclear()
monitor.write("Base64: "..msg)
msg = base64.decode(msg)
newLine()
monitor.write("AES: "..msg)
msg = AES.decrypt(password, msg)
newLine()
if msg == nil then msg = "error" end
monitor.write("MSG : "..msg)
modem.closeAll()
end
the problem :
msg = AES.decrypt(password, msg)
[color=#FF0000]monitor.write("MSG : "..msg) -- error ([/color][color=#FF0000]msg = nil)[/color]
with script like that, its good :
msg = AES.decrypt(password, msg)
[color=#008000]if msg == nil then msg = "decrypt error (bad pwd)" end[/color]
monitor.write("MSG : "..msg)
:rolleyes:/> thank you !