In the RIA world, Flex and AIR applications have really taken off. With that has come increased adoption by Fortune 500 companies and new enterprise-level apps taking advantage of the Adobe Flash platform. Application and data security should always be a concern of the Flex/AIR developer. The level of paranoia the developer should implement must be weighed against the goals of the project. For example, if you’re developing an open source or advertising-supported application intended for a wide public audience, you probably want to implement fairly minimal security measures in order to reach the widest audience and limit the amount of time you spend managing users in the system. On the other hand, if you’re being contracted to write a dashboard application for a large company or government for internal use, you’d probably want to implement security measures at the high-end of the spectrum.
In this series of three articles on the topic of Encryption in Flex Applications, we’ll first cover a basic data encryption and storage example in a Flex application. In article two, we’ll look at using an interface and doing some minimal encryption on a SWC file to protect an example commercial library we want to sell. In the final installment, we’ll take a look at using some of the features of NitroLM.com which is a commercial API for user registration, management, and entire application encryption.
In Adobe’s newly-released version of AIR 1.0, they provide an API for storing encrypted data to the hard drive. The flash.data.EncryptedLocalStore class uses the Windows DPAPI or KeyChain on MacOS to store and retrieve encrypted data as a ByteArray. Unfortunately, this capability isn’t available to us in a Flex application. In this example, I’ll demonstrate creating similar functionality by encrypting data stored in a local SharedObject.
The first thing we need is to download an encryption library to use in our Flex application. I’m using AS3Crypto (http://crypto.hurlant.com) created by Henri Torgemane. I recommend downloading the source code so you can debug easier and see how the encryption is working.
In this example (view-source enabled), the user can save a username and password between runs of the application to be used by a web service. It’s not totally secure since the randomly generated key is stored along with the encrypted data. I’ll leave it as an exercise for the reader to come up with clever ways to obfuscate the key or use alternative server-side repositories that are more secure.
FlexEncryptionExample1 example
Let’s walk through the code. We have two main methods, encryptedLoad() and encryptedSave(). encryptedSave() generates a random 16 byte key, and runs the AES-128 encryption algorithm on our username and password that we’ve packaged into a ByteArray.
private function encryptedSave():void
{
var so:SharedObject = SharedObject.getLocal("encryptedStore");
var key:ByteArray = new ByteArray();
var random:Random = new Random();
random.nextBytes(key, 16);
var cleartextBytes:ByteArray = new ByteArray();
cleartextBytes.writeUTF(username.text);
cleartextBytes.writeUTF(password.text);
var aes:ICipher = Crypto.getCipher("aes-ecb", key, Crypto.getPad("pkcs5"));
aes.encrypt(cleartextBytes);
var dataToStore:ByteArray = new ByteArray();
dataToStore.writeBytes(key);
dataToStore.writeBytes(cleartextBytes);
so.data.ws_creds = dataToStore;
so.flush();
username.text="";
password.text="";
}
encryptedLoad() reads in our key and uses it to decrypt the rest of the ByteArray. The values are then loaded into their respective form fields from the decrypted ByteArray.
private function encryptedLoad():void
{
var so:SharedObject = SharedObject.getLocal("encryptedStore");
var dataToLoad:ByteArray = so.data.ws_creds;
var key:ByteArray = new ByteArray();
dataToLoad.readBytes(key, 0, 16);
var encryptedBytes:ByteArray = new ByteArray();
dataToLoad.readBytes(encryptedBytes);
var aes:ICipher = Crypto.getCipher("aes-ecb", key, Crypto.getPad("pkcs5"));
aes.decrypt(encryptedBytes);
encryptedBytes.position = 0;
username.text = encryptedBytes.readUTF();
password.text = encryptedBytes.readUTF();
}
Hopefully with this example, you can start to see some of the possibilities for encrypting your data using Adobe Flex/AIR.
相关推荐
1. **FlexCAN简介**:FlexCAN是一种灵活的CAN控制器,支持CAN 2.0A、CAN 2.0B和CAN FD(Flexible Data-Rate)协议,能够处理不同速率的数据传输。 2. **CAN总线**:CAN总线是汽车电子系统中的标准通信协议,通过多...
Blazeds是一个强大的Java服务器端技术,主要用于构建富互联网应用程序(Rich Internet Applications,简称RIA)。它结合了Adobe Flex客户端技术和Java服务器端技术,提供了一种高效的数据通信解决方案,使得Flex应用...
Flex Messaging是Adobe Flex框架的一部分,它提供了一个强大的实时通信平台,允许客户端(通常是Flex应用程序)与服务器进行双向数据交换。4.7.3版本是这个组件的一个更新,它可能包含了性能提升、错误修复以及新的...
Flex-PHP-DES 加密解密包是一款专为PHP开发者设计的工具,它实现了DES(Data Encryption Standard)加密算法,并提供了与Adobe Flex应用程序之间的数据安全交互。DES是一种广泛使用的对称加密算法,常用于保护敏感...
知识点1:单片机的应用 * 单片机是计算机系统的核心组件之一, Responsible for controlling and processing data。 * 在该设计中,AT89C51单片机作为系统的主控部件,实现整个电路的信号控制、数据运算处理等功能...
- **Flash程序存储器**:用于存储程序代码和非易失性数据。 - **RAM内存**:为应用程序提供运行时存储空间。 ##### 能量管理 - **能量管理单元**:提供多种低功耗模式。 - **电源监控器**:包括电压监测、电源复位...
- BlazeDS或LiveCycle Data Services:Adobe提供的中间件,允许Flex应用程序与Java或.NET服务进行数据交换,包括Socket通信。 2. **C#服务端开发**: - `System.Net.Sockets.Socket`类:用于创建和管理Socket连接...
### Flex Data Services (FDS) 简介 Flex Data Services (FDS),也被称为 Flex Data Services 2 或 FDS2,在 Adobe Flex 开发框架中扮演着至关重要的角色。它并非传统的服务器插件,而是作为一个独立的 Web 应用...
Flex是Adobe公司推出的一种开源框架,主要用于构建富互联网应用程序(Rich Internet Applications,RIA)。它基于ActionScript编程语言和MXML标记语言,为开发者提供了一种高效、强大的方式来创建具有丰富用户界面的...
sudo apt-get install build-essential binutils cpp fetchmail flex gcc libarchive-zip perl libc6-dev libpcre3 libpopt-dev lynx m4 make ncftp nmap perl perl-modules unzip zip zlib1g-dev autoconf automake...
标题中的“flex的远程对象调用”指的是在Adobe Flex应用程序中使用Remote Object(RO)服务进行远程通信的技术。Flex是一个开源的、基于ActionScript的框架,用于构建富互联网应用程序(RIA)。通过RO服务,Flex应用...
Flex是Adobe开发的一种富互联网应用程序(RIA)开发框架,基于ActionScript 3.0,它可以创建具有动态图形和交互性的Web应用。Socket接口是Flex中用于网络通信的基础组件,允许客户端与服务器进行双向数据流通信。在...
Flex是Adobe公司开发的一种开放源代码的、基于XML的标记语言,主要用于创建富互联网应用程序(RIA)。它允许开发者构建交互性强、视觉效果丰富的用户界面,常用于Web应用中。Java则是一种广泛使用的面向对象的编程...
Flex是一种开源的富互联网应用程序(RIA)开发框架,由Adobe公司提供,主要用于构建交互性强、用户体验优秀的Web应用。它基于ActionScript编程语言和Flash Player运行环境,能够创建动态、响应式的用户界面。BlazeDS...
LCDS(LiveCycle Data Services),原名为Flex Data Service(FDS),是Adobe提供的一款强大的数据服务解决方案,专门针对Flex和Flex应用的后端数据交互。它建立在Java平台之上,同时也支持ColdFusion版本,为Flex...
1. **Flex基础**:Flex是一种基于ActionScript的开发环境,用于创建交互式、图形丰富的Web应用程序。它使用MXML和ActionScript语言,支持事件驱动和面向对象编程。 2. **LiveCycle Data Services (LCDS)**:LCDS是...
ActionScript 3.0是Flash Platform的核心编程语言,广泛用于开发富互联网应用程序(RIA)。Flex是基于ActionScript 3.0的开源框架,它提供了一套组件库和开发工具,简化了RIA的构建过程。 1. **ActionScript 3.0...
9. **安全性**:考虑到聊天应用通常涉及用户隐私,Flex聊天程序需要考虑安全措施,如数据加密传输、身份验证和访问控制等,以保护用户信息的安全。 10. **部署和优化**:完成开发后,Flex应用程序需要打包成SWF文件...
Flex BlazeDS通信是一种在富互联网应用程序(RIA)中实现客户端与服务器端数据交互的技术。它主要涉及Adobe Flex作为前端开发工具,以及BlazeDS作为后端数据服务的中间件。BlazeDS是Adobe官方推出的一个开源项目,...
Flex聊天程序客户端是一款基于Adobe Flex技术构建的在线通信应用程序,它允许用户进行实时的文字、音频或视频交流。Flex是ActionScript 3.0的一个开发框架,主要用于构建富互联网应用程序(Rich Internet ...