2013-08-25 34 views
0

加密视频文件我需要制作闪光灯swf播放加密flv/MP4视频。我试过这个.. HTTP://www.veryinteractivepeople.com/?p=525使用动作脚本3加密视频文件,并从播放swf

这里我们想把flv文件放到swf中并加密它。但我想单独加密flv/MP4并从主swf播放

我不是专家关于动作脚本3。但我会尝试。请告诉我一些解决方案。

+0

你有什么真正尝试过自己吗?你将以什么方式实现你的需求? – Max

回答

1

您需要使用空网络连接和网络流以“数据生成模式”准备视频。然后使用URLRequest加载加密的字节,解密它们,并将字节附加到网络流中。

var nc = new NetConnection(null); 
var ns = new NetStream(nc); 

var encryptedBytes = .. get encrypted bytes from URLRequest ... 

var decryptedBytes = .. your decryption function .. 

ns.appendBytes(decryptedBytes); 
var video = new Video(); 
addChild(video); 
video.attachNetStream(ns); 
ns.play(null); 
0

我想这个代码.... http://www.veryinteractivepeople.com/?p=525

package 
{ 
    import flash.display.Sprite; 
    import flash.display.Loader; 
    import flash.display.Sprite; 
    import flash.events.Event; 

    import flash.utils.ByteArray; 

    [SWF(width="770", height="490", frameRate="31", backgroundColor="#FFFFFF")] 
    public class ProtectedSWF extends Sprite 
    { 
     //replace "encrypted.swf" to the name of your encrypted SWF file 
     [Embed(source="encrypted.swf", mimeType="application/octet-stream")] 
     private const EmbeddedSWF:Class; 

     //put your encryption key here 
     private static const KEY:String="WRITE_YOUR_OWN_CODE!"; 

     public function ProtectedSWF() 
     { 
      var binaryData:ByteArray = new EmbeddedSWF(); 
      if(binaryData.length != 0) 
      { 
       XOR(binaryData,KEY); 
       var animationLoader:Loader = new Loader(); 
       animationLoader.loadBytes(binaryData); 
       addChild(animationLoader); 
      } 
     } 
     private static function XOR(binaryData:ByteArray, key:String):void{ 
      var keyIndex:Number=0; 
      for(var i:Number=0;i<binaryData.length;i++){ 
       binaryData[i]=binaryData[i]^key.charCodeAt(keyIndex); 
       keyIndex++; 
       if(keyIndex>=key.length) 
        keyIndex=0; 
      } 
     } 
    } 
}