如何使用 Flash 加密/解密 FLV

发布于 2024-12-10 10:33:28 字数 392 浏览 0 评论 0原文

我正在开发一个 Windows 应用程序(在 .NET 中创建),其功能之一是使用 SWF 组件播放本地 FLV。

现在我需要创建一个加密应用程序以确保这些 FLV 无法自由播放,只有 SWF 播放器知道如何解密该文件(使用从 .NET 应用程序收到的密钥)。

我正在考虑创建一个 Air 应用程序来编码我的 flvs(也许是 ByteArray 类?),使用某种算法根据键字符串对字符进行洗牌/取消洗牌。

我的主要需求是如何使用 Air/Flash 对文件进行编码/解码。 我尝试了几次,只是尝试加载 FLV,转换为 ByteArray,然后保存新的 FLV,但这个新的 FLV 无法播放。打开 Notepad++,我注意到该文件在 FLV 标头之前有几个字符。

有人知道如何正确地做到这一点吗?谢谢!

I'm working on an Windows application(created in .NET) which one of its functions is to play local FLVs using SWF components.

Now I need to create an encryption application to make sure those FLVs cannot be played freely, only the SWF player will know how to decrypt that file(using a key received from .NET app).

I was thinking of creating an Air app to encode my flvs (maybe ByteArray class?), using some algorithm to shuffle/unshuffle characters based in a key string.

My main need is how to encode/decode a file using Air/Flash.
I tried some times, just trying to load a FLV, convert to ByteArray, then save the new FLV, but this new FLV won't play. Opening into Notepad++, I noticed the file have a few characters before it's FLV header.

Anyone knows how to do that correctly? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

世态炎凉 2024-12-17 10:33:28

只有 SWF 播放器知道如何解密该文件。

如果有人有权访问 SWF,他们就可以对其进行反编译,并了解如何解密您的 FLV。

更好的方法是使用 AES 等加密它们,然后从服务器获取密钥。

如果您不担心人们反编译您的 SWF,只需执行任何会导致媒体播放器无法打开它的操作即可。

是的,您可以使用 ByteArray 来修改您的 FLV。

关于额外的字节,您不应该“转换”为 ByteArray,当您收到它时它应该已经是这种格式。听起来好像您以某种方式将其放在 String 中,并且使用了 writeUTF,它在开头写入长度。

only the SWF player will know how to decrypt that file.

If somebody has access to the SWF, they can decompile it, and find out how to decrypt your FLVs.

A better way would be to encrypt them with something like AES, then get the key from a server.

If you're not worried about people decompiling your SWF, just do anything that will cause media players to fail to open it.

Yes, you would use ByteArray to modify your FLV.

About the extra bytes, you shouldn't be "converting" to ByteArray, it should already be in that format when you receive it. It sounds like you somehow had it in a String and you used writeUTF, which writes the length at the beginning.

み青杉依旧 2024-12-17 10:33:28

这是我通过我的经历和谷歌搜索取得的成就的一个例子。工作完美。

    public function Main():void 
    {           
        us.load(new URLRequest("file.ext"))
        us.addEventListener(Event.COMPLETE, onVideoLoaded);
    } 

    private function onVideoLoaded(e:Event):void
    {
        var bytes:ByteArray = new ByteArray();  
        us.readBytes(bytes, bytes.length, us.bytesAvailable);

        bytes = encrypt(bytes);         
        saveFile(bytes);
    }

    private function saveFile(bytes:ByteArray):void
    {           
        var fileStream:FileStream = new FileStream();
        fileStream.open(File.desktopDirectory.resolvePath("filename.ext"), FileMode.WRITE);
        fileStream.writeBytes(bytes, 0, bytes.length);
        fileStream.close();

        fileStream.addEventListener(OutputProgressEvent.OUTPUT_PROGRESS, onCompleteFile);
    }


    private function encrypt(bytes:ByteArray):ByteArray 
    {
        var i:int = bytes.length;
        while (i--)
        {
            bytes[i] += 128;
        }

        return bytes;
    }

使用 ROT128 加密文件,更多信息此处。

Here is a example of what I achieved throught my experiences and googling. Works perfectly.

    public function Main():void 
    {           
        us.load(new URLRequest("file.ext"))
        us.addEventListener(Event.COMPLETE, onVideoLoaded);
    } 

    private function onVideoLoaded(e:Event):void
    {
        var bytes:ByteArray = new ByteArray();  
        us.readBytes(bytes, bytes.length, us.bytesAvailable);

        bytes = encrypt(bytes);         
        saveFile(bytes);
    }

    private function saveFile(bytes:ByteArray):void
    {           
        var fileStream:FileStream = new FileStream();
        fileStream.open(File.desktopDirectory.resolvePath("filename.ext"), FileMode.WRITE);
        fileStream.writeBytes(bytes, 0, bytes.length);
        fileStream.close();

        fileStream.addEventListener(OutputProgressEvent.OUTPUT_PROGRESS, onCompleteFile);
    }


    private function encrypt(bytes:ByteArray):ByteArray 
    {
        var i:int = bytes.length;
        while (i--)
        {
            bytes[i] += 128;
        }

        return bytes;
    }

Using ROT128 to encrypt a file, more info here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文