|
|||
|
Hi!
I want to encode and decode a file in my application! Code example: //savetest function copyFile(){ var fileStream = new StringStream(); var outputStream = new StringStream(); var encodestring = new String(); var crystring = new String(); fileStream = fileStream.readFromFile("D:\\1-1.jpg"); encodestring = fileStream.readString(); trace (encodestring); crystring = Encryption.blowfishEncode("test", encodestring); trace (crystring); outputStream.writeString(crystring); var res = Dialogs.fileSave("jpg", "jpg", "img1.jpg"); outputStream.saveToFile(res); fileStream.close(); outputStream.close(); } FlashPlayer.setVariable("testvar", "test"); copyFile(); The File i want to encode is a jpg (i want to save the coded jpg on a cd and decode it then so i have to encode it first) If i look at the trace output the encodestring contains only a few caracters of the file (only the jpg header). I also tryed it with a loop and readLine. Maybee there is a better way to secure the pictures on the cd so that they only can be copied by the apllication. I am using SWFPro Trial - if this can be solved i can use it for my cd production so i buy it. Thx for help! |
|
|||
|
The content in a jpg file is a stream not a string. When you pass the sream to the "blowfishEncode" method, it will stop encrypting and return when it meet zero in the stream. So you only get the header of the jpg file. You must convert the stream to a string to encrypt it.
SWFKit doesn't provide any methods to convert a stream to a string. However, you can create a mail object and add the jpg file as an attachment. The mail object can be converted to string text. The sample shows how to do this. |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|