Bitmap Based Encryption

BlitzPlus Forums/BlitzPlus Programming/Bitmap Based Encryption

Arem(Posted 2004) [#1]
Hey. Im trying to create a program to encrypt a file to a bmp image and then decrypt it. It will be password based but that will come later. All ive coded right now is making the bmp out of the file.

file$=RequestFile("file?","*")
file1=ReadFile(file)
image=CreateImage(5000,1)
pos=0

While Not Eof(file1)
r=ReadByte(file1)
g=ReadByte(file1)
b=ReadByte(file1)
SetBuffer ImageBuffer(image)
Color r,g,b
Plot pos,1
Wend

SaveBuffer(ImageBuffer(image),"test.bmp")
CloseFile(file1)
End

When i try to execute this code, i get a black image and an error message that says "Internal Error. Unable to release <unknown> object." Any ideas?


PantsOn(Posted 2004) [#2]
haven't tested.. but heres a few thoughts on the above code

reading 3 bytes at once (b4 doing another eof test) is the file size multiple of 3?

you plot at pos,1 should it be pos,0 (image height 1 pixel)

you don't increase the pos position so all pixel stuff will be at 0,0

just a few thoughts


CS_TBL(Posted 2004) [#3]
"Internal Error. Unable to release <unknown> object."


before you end the program, type:

setbuffer desktopbuffer()


You must always point to a buffer .. if you previously switched to a canvasbuffer or imagebuffer then you must return to the desktopbuffer again..


Arem(Posted 2004) [#4]
Thanks guys. I was kinda stupid about some of it LOL. But i didnt know about the desktopbuffer thing.