Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-20-2007, 03:52 PM
Member
 
Join Date: Oct 2005
Posts: 87
Default How to convert Binary Stream to Numeric Array

I want to encrypt a binary file, so I read it with Read mathod of ADO.stream, get a number of bytes(say 16 bytes per time), I need to convert it to an Array of Integer, then I can use XOR to encrypt it !(in your manual says that Xor can only worked on Integers)
I can't find methed to do that, do kindly do me a favor!
thanks lot !
Reply With Quote
  #2 (permalink)  
Old 04-22-2007, 04:12 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:How to convert Binary Stream to Numeric Array

You may use the getLong and write method to read integers from and write integers to a stringstream. And please be sure to check the length of the stringstream, it may not be exactly times of 4 (length of an integer).
Reply With Quote
  #3 (permalink)  
Old 04-22-2007, 04:50 PM
Member
 
Join Date: Oct 2005
Posts: 87
Default Re:How to convert Binary Stream to Numeric Array

thanks for your answer!
I'm sorry that forgot tell you that the Binary Files are stored in Access MDB, so I had to use ADO.stream instead of stringStream.
in fact I've tried stringStream, it seems can't work with
Ado.Fields object.
code like:
......
var stm = new stringStream()
stm.write(rs.Fields(1))
trace(stm.length) // get 0!
......
didn't work,that is: write nothing to stm;
Reply With Quote
  #4 (permalink)  
Old 04-22-2007, 05:03 PM
Member
 
Join Date: Oct 2005
Posts: 87
Default Re:How to convert Binary Stream to Numeric Array

the Fields(1) above is a Blob typed field, store a Binary File
Reply With Quote
  #5 (permalink)  
Old 04-23-2007, 02:12 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:How to convert Binary Stream to Numeric Array

When you use ActiveX component in ffish script, binary data will be converted to stringstream automatically.
Reply With Quote
  #6 (permalink)  
Old 04-23-2007, 08:51 AM
Member
 
Join Date: Oct 2005
Posts: 87
Default Re:How to convert Binary Stream to Numeric Array

I don't understand what's your mean?
could you please show me a code sample

Reply With Quote
  #7 (permalink)  
Old 04-23-2007, 08:56 AM
Member
 
Join Date: Oct 2005
Posts: 87
Default Re:How to convert Binary Stream to Numeric Array

How can I read/write Ado.Fields with StringStream's get/put or read/write method?
Fields adove is a Blob typed field
Reply With Quote
  #8 (permalink)  
Old 04-23-2007, 09:25 AM
Member
 
Join Date: Oct 2005
Posts: 87
Default Re:How to convert Binary Stream to Numeric Array

Oh! I see!
.......
//var stm=new StringStream();
trace(typeof(rs.Fields(0))) //
stm = rs.Fields(0).value
for (var i=0;i<10;i++){
trace(i+":"+stm.getLong())
}
trace(stm.length) // get right len now!
var fd = appPath + "_chen.swf"
stm.saveToFile(fd); // check'd OK
.........


how can I write modified stm Back to Database?
......
rs.Fields(0).value = modifieldStringStream;
....
rs.update()
....
Reply With Quote
  #9 (permalink)  
Old 04-23-2007, 09:47 AM
Member
 
Join Date: Oct 2005
Posts: 87
Default Re:How to convert Binary Stream to Numeric Array

...............
trace(stm.length) //
stm.putPos = stm.length;
stm.write("TEST")
trace(stm.length) // length increased 4
rs.Fields(0).value = stm
rs.update() // database update properly!
...............

Everything is OK now !
THANKs alot for your support!

Any further suggestions do you have?
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 04:15 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.