Sign a string in an open source code

Suppose I have a program that generate a string. I want this string to be signed with a private key, such that I can be sure that the string was actually generated by the program and not in any other way.

The only way I can do this is by HIDING the string inside the code, but in the case of open source programs you need a way to insert this key only at compile time.

What is the best/easier way to achieve this task (using C++)?

(For C++ I was thinking at some preprocessor directive that generate some key at compile time.)


Well, you can use precompiler constant which could be passed to your compiler with -D flag in your Makefile.

In conjunction with this, you can use configure script to generate Makefile, to calculate and set this constant.

-D name=definition The contents of definition are tokenized and processed as if they appeared during translation phase three in a ‘#define’ directive. In particular, the definition will be truncated by embedded newline characters. If you are invoking the preprocessor from a shell or shell-like program you may need to use the shell's quoting syntax to protect characters such as spaces that have a meaning in the shell syntax.

If you wish to define a function-like macro on the command line, write its argument list with surrounding parentheses before the equals sign (if any). Parentheses are meaningful to most shells, so you will need to quote the option. With sh and csh, -D'name(args...)=definition' works.

Need Your Help

php merge json arrays into one array

php arrays json file merge

I am trying to loop through some json files, and combine them into one json file. My plan is to have a global $allData array, and just merge new candidates into them.

custom map service mapguide openlayers

service map openlayers mapguide

Recently got started on MapGuide. Kind of lost. The amount of information available on the web is overwhleming. My requirement is to use custom maps of a campus and building and navigate from a ca...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.