Compile-time string encryption

前端 未结 8 2287
悲哀的现实
悲哀的现实 2020-12-28 17:08

I don\'t want reverse-engineers to read the plain-text of hardcoded strings in my application. The trivial solution for this is using a simple XOR-Encryption. The problem is

8条回答
  •  时光取名叫无心
    2020-12-28 17:39

    I think you have to do something like what is done when using gettext (i18n) :

    • use a macro like your CRYPT.
    • use a parser that will crypt string when it finds CRYPT.
    • write a function that decrypt, called by your macro.

    For gettext, you use the _() macro that is used to generate the i18ned string dictionnary and that call the gettext function.

    By the way, you have to manage i18n too :), you will need something like :

    _CRYPT_()
    _CRYPT_I18N_()
    

    You have to manage that with your build system to make it maintenable. I do that with gettext...

    My 2 cents

提交回复
热议问题