加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex中Des加密解密

发布时间:2020-12-15 03:52:08 所属栏目:百科 来源:网络整理
导读: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.encr
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);


  1. //String转ByteArray??
  2. ????????????public?function?convertStringToByteArray(str:String):ByteArray??
  3. ????????????{??
  4. ????????????????var?bytes:ByteArray;??
  5. ????????????????if?(str)??
  6. ????????????????{??
  7. ????????????????????bytes=new?ByteArray();??
  8. ????????????????????bytes.writeUTFBytes(str);??
  9. ????????????????}??
  10. ????????????????return?bytes;??
  11. ????????????}??
  12. ????????????//ByteArray转String??
  13. ????????????public?function?convertByteArrayToString(bytes:ByteArray):String??
  14. ????????????{??
  15. ????????????????var?str:String;??
  16. ????????????????if?(bytes)??
  17. ????????????????{??
  18. ????????????????????bytes.position=0;??
  19. ????????????????????str=bytes.readUTFBytes(bytes.length);??
  20. ????????????????}??
  21. ????????????????return?str;??
  22. ????????????}?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读