Giter VIP home page Giter VIP logo

encryptpng's Introduction

EncryptPNG

png加密解密

参考: https://blog.csdn.net/ldpjay/article/details/46454999

用法:

  1. 在 cocos 目录下新建文件夹 ext ,将 CCAES.cpp、CCAES.h、CCDecryptImage.cpp、CCDecryptImage.h 拷贝到其中。

  2. IDE中将ext目录加入搜索

  3. CCImage.cpp:

bool Image::initWithImageFile(const std::string& path)
{
    ......

    if (!data.isNull())
    {
        // 图片文件解密
        if (ext::AnalyzeExtension(path)[1] == ext::TARGET_EXTENSION)
		{
			auto image_data = ext::DecryptImage(path, data);
			ret = initWithImageData(&image_data[0], image_data.size());
		}
		else
		{
			ret = initWithImageData(data.getBytes(), data.getSize());
		}
    }
#endif // EMSCRIPTEN

    return ret;
}

bool Image::initWithImageFileThreadSafe(const std::string& fullpath)
{
    ......

    if (!data.isNull())
    {
        // 图片文件解密
        if (ext::AnalyzeExtension(fullpath)[1] == ext::TARGET_EXTENSION)
		{
            auto image_data = ext::DecryptImage(fullpath, data);
			ret = initWithImageData(&image_data[0], image_data.size());
		}
		else
		{
			ret = initWithImageData(data.getBytes(), data.getSize());
		}
    }

    return ret;
}
  1. 密钥和扩展名可以在CCDecryptImage.h中设置:
......

namespace ext
{
    /* 解密扩展名 */
    static std::string TARGET_EXTENSION = ".epng";

    /* 解密密钥 */
    //如果用附带的工具加密的时候输入的是8888888888888888的话,则密钥可以设置如下
    static aes_key SECRET_KEY = { '8', '8','8','8','8', '8','8','8','8', '8','8','8','8', '8','8','8'};

    ......
}

...

encryptpng's People

Contributors

qwertylevel3 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.