使用预处理器加密 [英] encrypting with preprocessor

查看:72
本文介绍了使用预处理器加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想构建一个加密宏集,可以加密:


char secret [] = CRYPT(" ; KungFu);


到任何不可读的东西,然后有一个功能:

char * DECRYPT(char * str)

{

...

}


我认为加密最多16个字符就足够了。 />
简单的XOR也足够了。关于如何做到的任何想法?


-

-Gernot

int main(int argc,char ** argv){printf

("%silto%c%cf%cgl%ssic%ccom%c"," ma",58,''g'',64," ba" ,46,10);}


________________________________________

寻找好游戏?亲自动手吧!

GLBasic - 你可以这样做
www.GLBasic .com

推荐答案

Gernot Frisch写道:
Gernot Frisch wrote:




我想构建一个加密宏集,可以加密:


char secret [] = CRYPT(" KungFu"); <对于任何不可读的东西都是
,然后有一个功能:

char * DECRYPT(char * str)

{

...

}


我认为加密最多16个字符就足够了。

简单的XOR也足够了。有关如何做到这一点的任何想法?
Hi,

I want to build a encryption macro set, that can crypt:

char secret[] = CRYPT("KungFu");

to anything unreadable, and then have a function:
char* DECRYPT(char* str)
{
...
}

I think it would be suffictient to encrypt a maximum of 16 characters.
Simple XOR would suffice, too. Any ideas of how that can be done?



是的,但解释起来有点长,需要很多宏(大约

200-400宏)才能完成只要你接受写:


char secret [] = CRYPT(K,u,n,g,F,u);


而不是字符串作为参数,然后CRYPT可以输出一个加密的

字符串的八进制代码。


我知道这不是一个答案,但使用宏执行此操作确实需要

a" package"用于操纵令牌列表的宏(例如map,cat,merge,

等...)以及一组算术和逻辑运算。我有一个这样的

包,所以我可以根据要求提供它,但它没有任何文件。


a +,ld。

Yes, but it is a bit long to explain and needs a lot of macros (about
200-400 macros) to do it as far as you accept to write:

char secret[] = CRYPT(K,u,n,g,F,u);

instead of a string as a parameters, then CRYPT could output a crypted
string of octal codes for example.

I know this is not an answer, but doing this with macros really require
a "package" of macros to manipulate list of token (e.g. map, cat, merge,
etc...) plus a set of arithmetic and logic operations. I have a such
package so I can provide it on request but it hasn''t any documentation.

a+, ld.




" Laurent Deniau" < la ************ @ cern.chschrieb im Newsbeitrag

新闻:e9 ********** @ sunnews.cern.ch .. 。

"Laurent Deniau" <la************@cern.chschrieb im Newsbeitrag
news:e9**********@sunnews.cern.ch...

Gernot Frisch写道:
Gernot Frisch wrote:

>

我想建立一个加密宏集,可以加密:

char secret [] = CRYPT(KungFu);

任何不可读的东西,然后有一个函数:
char * DECRYPT(char * str)
{
...


我认为加密最多16个就足够了
人物。简单的XOR也足够了。关于如何做到这一点的任何想法?
>Hi,

I want to build a encryption macro set, that can crypt:

char secret[] = CRYPT("KungFu");

to anything unreadable, and then have a function:
char* DECRYPT(char* str)
{
...
}

I think it would be suffictient to encrypt a maximum of 16
characters. Simple XOR would suffice, too. Any ideas of how that
can be done?



是的,但解释起来有点长,需要很多宏

(约200-400个宏)才能完成只要你接受写:


char secret [] = CRYPT(K,u,n,g,F,u);


而不是字符串作为参数,然后CRYPT可以输出一个

加密的八进制代码串。


我知道这不是一个答案,但用宏实现这一点真的需要一个包。宏来操纵令牌列表(例如map,

cat,merge等等)以及一组算术和逻辑运算。我有一个这样的包装,所以我可以根据要求提供它,但它没有任何

文件。


Yes, but it is a bit long to explain and needs a lot of macros
(about 200-400 macros) to do it as far as you accept to write:

char secret[] = CRYPT(K,u,n,g,F,u);

instead of a string as a parameters, then CRYPT could output a
crypted string of octal codes for example.

I know this is not an answer, but doing this with macros really
require a "package" of macros to manipulate list of token (e.g. map,
cat, merge, etc...) plus a set of arithmetic and logic operations. I
have a such package so I can provide it on request but it hasn''t any
documentation.



你能否解释如何制作它?

can you give a grief explaination on how to make it?


Gernot Frisch说:
Gernot Frisch said:




我想构建一个加密宏集,可以加密:


char secret [] = CRYPT(" KungFu");


到任何不可读的东西,然后有一个函数:

char * DECRYPT(char * str)

{

...

}


我认为这是足够的加密最多16个字符。

简单的XOR也足够了。有关如何做到这一点的任何想法?
Hi,

I want to build a encryption macro set, that can crypt:

char secret[] = CRYPT("KungFu");

to anything unreadable, and then have a function:
char* DECRYPT(char* str)
{
...
}

I think it would be suffictient to encrypt a maximum of 16 characters.
Simple XOR would suffice, too. Any ideas of how that can be done?



#define CRYPT(x)my_encryption_routine(x)


我认为你没有打电话就可以做到这一点一个函数,虽然我会对看到一个反例非常感兴趣。


我的理由如下:你需要这样做在单个表达式中

不涉及复合语句(因为复合语句是

不仅仅是表达式,所以它们不会产生一个值,这不会如果他们与逗号操作员玩得很好的话,他们会这么糟糕

- 但他们不会这样做。一个函数很好地解决了这些问题,但我没有看到任何其他方法。我猜想在

C99中你可以使用内联函数。


< OT>

如果你正好在使用gcc,我认为你可以使用GNU扩展,

允许宏中的复合语句产生结果。一个gcc新闻组

将是一个讨论这个问题的好地方。

< / OT>


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)

#define CRYPT(x) my_encryption_routine(x)

I don''t think you can do this without calling a function, although I would
be very interested in seeing a counter-example.

My reasoning is as follows: you''d need to do this in a single expression
that doesn''t involve a compound statement (because compound statements are
not mere expressions, so they don''t yield a value, which wouldn''t be so bad
if they played nice with comma operators - but they don''t). A function gets
around these problems nicely, but I don''t see any other way to do it. In
C99 you could use an inline function, I suppose.

<OT>
If you happen to be using gcc, I think you can use a GNU extension which
allows compound statements in macros to yield results. A gcc newsgroup
would be a good place to ask about this.
</OT>

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


这篇关于使用预处理器加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆