Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-04-2004, 08:43 AM
Junior Member
 
Join Date: Aug 2004
Posts: 1
Default FileStream encode

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!

Reply With Quote
  #2 (permalink)  
Old 08-04-2004, 04:37 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:FileStream encode

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.
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:42 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.