Flex中Des加密解密

AS3中Des加密解密

懒骨头(http://blog.csdn.com/iamlazybone)

 

as3crypto:一个as3的关于加解密的开源项目

http://code.google.com/p/as3crypto/

2

myKeyStr="123456";

myKey=new ByteArray();

myKey.writeUTFBytes(myKeyStr);

myDes=new DESKey(myKey);

3

tmpByteArray=convertStringToByteArray(txt1.text);

myDes.encrypt(tmpByteArray, 0);

txt2.text=convertByteArrayToString(tmpByteArray);

myDes.decrypt(tmpByteArray, 0);

txt3.text=convertByteArrayToString(tmpByteArray);

4

//String转ByteArray public function convertStringToByteArray(str:String):ByteArray { var bytes:ByteArray; if (str) { bytes=new ByteArray(); bytes.writeUTFBytes(str); } return bytes; } //ByteArray转String public function convertByteArrayToString(bytes:ByteArray):String { var str:String; if (bytes) { bytes.position=0; str=bytes.readUTFBytes(bytes.length); } return str; } 

你可能感兴趣的:(加密,String,function,Flex,解密)