当前位置:网站首页>File decryption in webgame development
File decryption in webgame development
2022-06-26 11:56:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
The last one is about file encryption , This article records how to load and display pictures .
Because the picture file is encrypted , Has become a binary stream file ( A lot of crap ), Only use URLStream To load resources .
There is one caveat here :URLStream The read operation in is non blocking , Must be used before reading data bytesAvailable Property to determine whether enough data can be obtained , How not to get enough data , Will lead to EOFError abnormal .
Main idea :
1、 Load encrypted resources , Use URLStream
2、 Call decryption method , Get the decrypted data
3、 Use Loader Class loadBytes Method load resource
1: var urlLoader:URLStream = new URLStream(); 2: var url:String = getEncryptURL(url); // Through the resources that need to be loaded url, To get the address of the resource that needs to be loaded , Such as xx.png Actual will request xx.p 3: 4: // monitor urlLoader Events 5: //Event.Complete、IOErrorEvent.IO_ERROR、ProgressEvent.PROGRESS、HTTPStatusEvent.HTTP_STATUS、Event.OPEN 6: 7: var req:URLRequest = new URLRequest(url); 8: 9: urlLoadedCount = 0; 10: 11: urlLoader.load(req); 12: 13: 14: 15: 16: 17: //onCompleteHandler In the method 18: var byte:ByteArray; 19: var byteLen:int; 20: 21: try 22: { 23: byteLen = urlLoader.bytesAvailable; 24: } 25: catch(e:Error) 26: { 27: if (urlLoadedCount++ > 3) 28: { 29: return ; 30: } 31: 32: //reload Reload , Until more than 3 Time 33: 34: return ; 35: } 36: 37: urlLoadedCount = 0; 38: 39: byte = new ByteArray(); 40: urlLoader.readBytes(byte, 0, byteLen); 41: byte = EncryptUtils.DeEncrypt(byte); // Decrypt the data , It corresponds to the encryption method in the previous article 42: byte.position = 0; 43: 44: // Start loading pictures 45: var loader = new Loader(); 46: 47: // monitor Event.Complete event 48: loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadImgCompleteHandler); 49: 50: var context:LoaderContext = new LoaderContext(); 51: context.applicationDomain = ApplicationDomain.currentDomain; 52: context.securityDomain = SecurityDomain.currentDomain; 53: 54: loader.loadBytes(byte, context); 55: 56: 57: //loadImgCompleteHandler Method 58: here loader.content Have been to Bitmap The class , Use addChild You can finish loading the picture 59: 60: 61: // If you want to load xml、txt And so on , This method is not required , Use byte.readUTFBytes(byte.bytesAvailable) You can get the decrypted string 62: More reference :
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/133958.html Link to the original text :https://javaforall.cn
边栏推荐
- I want to know how the top ten securities firms open accounts? Is online account opening safe?
- Apiccloud implements the document download and preview functions
- Refined operation, extending the full life cycle value LTV
- 杜比全景音效简介
- 深度学习中的FLOPs和Params如何计算
- 24 database interview questions that must be mastered!
- 2021 q3-q4 investigation report on the use status of kotlin multiplatform
- Splicing full paths and uploading multiple pictures of laravel admin when laravel uses OSS
- flannel的host-gw与calico
- 统计遗传学:第一章,基因组基础概念
猜你喜欢

flannel的host-gw与calico

Machine learning SVM - Experimental Report
![Compréhension approfondie de l'expérience de port série stm32 (registre) [Tutoriel de niveau nounou]](/img/b2/f09e220918a85b14a1993aa85f7720.png)
Compréhension approfondie de l'expérience de port série stm32 (registre) [Tutoriel de niveau nounou]

Apiccloud implements the document download and preview functions

Redis best practices? If I don't feel excited after reading it, I will lose!!

PC QQ大廳 上傳更新 修改versionInfo

Omni channel member link - tmall member link 3: preparation of member operation content

Redis的最佳实践?看完不心动,算我输!!

Quantitative elementary -- akshare obtains stock code, the simplest strategy

科技兴关,荣联与天津海关共建基因组数据库及分析平台
随机推荐
18: Chapter 3: development of pass service: 1: SMS login & registration process, introduction; (SMS verification code is used here)
Change calico network mode to host GW
哈希表的前置知识---二叉搜索树
Machine learning linear regression - Experimental Report
How do consumer goods enterprises formulate membership interests?
word中涂黑的方块
证券账户一般需要在哪里开通 开户安全吗
The best CMDB system
Is it safe to open a securities account
FastRCNN
How to prevent weight loss under Gao Bingfa?
express在nodejs中的基本使用
Common problems and Thoughts on member operation management
leetcode 715. Range module (hard)
HUST网络攻防实践|6_物联网设备固件安全实验|实验三 FreeRTOS-MPU 保护绕过
科技兴关,荣联与天津海关共建基因组数据库及分析平台
Prospering customs through science and technology, Ronglian and Tianjin Customs jointly build a genomic database and analysis platform
Solidworks渲染技巧如何不显示边线--显示样式设定
How can we reach members more effectively?
19:第三章:开发通行证服务:2:在程序中,打通阿里云短信服务;(仅仅是打通阿里云短信服务器,不涉及具体的业务开发)