Is there a way to envelope Adobe AIR (SWF/Flex) application into C# application to use HASP protection

StackOverflow https://stackoverflow.com/questions/16495045

Domanda

We have an Adobe AIR application which uses Flex Framework. It was initially built for browser version, but now we also need to use it as stand-alone application. This is possible to do using Adobe AIR.

However we need to use IP protection with this application, for our server side app we use SafeNet (formerly Alladin) HASP keys. The same keys can be used for encrypting client stand-alone application, but set of languages supported by these keys is very limited and the easiest one would be C# (.NET).

HASP protection works as follows: Execute encrypted binary, the decryption engine will check for USB key, if it is present the decryption mechanism written on key will decrypt the app into memory and execute it.

So the question is - what would be the best (easy and safe) way to embed SWF/AS files into C# app so these files will also be encrypted and therefore protected?

PS: I've read other questions regarding this matter and there is no way to use HASP protection with AIR directly, but some questions imply that it is possible to use SWF apps from C# app through ActiveX container.

PPS: Maybe that's a silly question, but I have no experience with C#, therefore any links, explanations, detailed instructions or examples will be appreciated.

È stato utile?

Soluzione 2

If all you want is to get your C# application encrypted with your swf/flex file, you can add the swf file to your C# application as an embedded resource. That way you'll only have one executable file, and it will contain the swf application.

When your C# application starts, you'll need to get the swf file and execute it (but it seems you know what to do here).

Here is a tutorial about how to embed binary resources in your application and extract them at execution time: http://www.dotnetscraps.com/dotnetscraps/post/Insert-any-binary-file-in-C-assembly-and-extract-it-at-runtime.aspx

Altri suggerimenti

This will load an embedded swf resource as a binary memory stream right into a form-embedded Flash player COM object (without creating a temporary file). Please note that the capabilities of the SWF will be limited to the "standard" Flash Player sandbox, you cannot embed & run AIR swfs that use desktop/extendedDesktop in this way.

I've created a GitHub Project with the full code and a sample swf.

1) compile the AIR application as an SWF

2) create a new C# Forms project

3) In the Solution Explorer, right-click on "References" and add "ShockWave Flash" from the COM tab

4) In the Solution Explorer, right-click on the project and select "Properties". Select the "Resources" tab in the newly opened form and add your SWF as a resource.

5) From the "General" tab in your Toolbox, drop a "ShockWave Flash" component on your form

6) Add the following code to your form:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Reflection;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;

namespace SwfRes
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            LoadBinSwf();
        }

        private void LoadBinSwf()
        {
            //Assuming your swf is called "Main.swf"
            byte[] swf = Properties.Resources.Main;

            MemoryStream memStream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(memStream);
            writer.Write(8 + swf.Length);
            writer.Write(0x55665566);
            writer.Write(swf.Length);
            writer.Write(swf);
            memStream.Seek(0, SeekOrigin.Begin);
            axShockwaveFlash1.OcxState = new AxHost.State(memStream, 1, false, null);
        }
    }
}

You can compile AIR applications as a native executable. For windows (for example), that's .exe. I imagine once you have compiled your AIR app for each platform natively, it should be easy to call/execute the AIR app from within C#.

The native installer (last I used it) was only available through the command line

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top