writing a few lines of comments that work in most languages
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
the code that is added to other code is intended to have no effect. this can be achieved as strictly being comments. the contents of these comments will be keys and the like or marker to source in a way that if no effort is made to remove what is added it can still be used as if nothing was added. for instance this can be a certificate marking the code as a licensed copy.
to have a reliable mechanism to validate the files you need to do much more, inserting a voodoo line is not enough.
google for certified archives (if you wish)
if the files are valid (instances of that language) they should still be valid after adding the lines. insertion in the middle is not a requirement. adding in the front or back (one of) is all that is needed. once the code is extracted, then it "proves" whatever it was meant to "prove". that may, for example, prove the identity of whoever added those lines (by means of the lines containing something particular that is encrypted by that entity using some PKC).
if the files are valid (instances of that language) they should still be valid after adding the lines. insertion in the middle is not a requirement. adding in the front or back (one of) is all that is needed. once the code is extracted, then it "proves" whatever it was meant to "prove". that may, for example, prove the identity of whoever added those lines (by means of the lines containing something particular that is encrypted by that entity using some PKC).
But the point others have made is that it does not prove the identity of whoever added those lines, it only proves that someone added those line (which they may have copied from elsewhere).
As stated above:
Quote:
Originally Posted by NevemTeve
If this is meant to prove authorship, then it won't work: anyone can add anything into a text-file.
Then the point stands that you can just do a "find -exec echo >>" operation for each file extension.
The point that "If this is meant to prove authorship, then it won't work" also stands.
In find the >> would redirect any output to one file.
You need a shell script that does the >> for each filename.
You can -exec an embedded shell code:
Code:
find . -type f -exec /bin/bash -c '
# shell code with the >>
' scriptname {} +
And put a shell code like I suggested in my previous post.
if the files are valid (instances of that language) they should still be valid after adding the lines. insertion in the middle is not a requirement. adding in the front or back (one of) is all that is needed. once the code is extracted, then it "proves" whatever it was meant to "prove". that may, for example, prove the identity of whoever added those lines (by means of the lines containing something particular that is encrypted by that entity using some PKC).
Not only anyone can add lines like that to any text file(s), but the same way anyone can alter those files by modifying something important inside.
The problem is that you don't know who added those voodoo lines to the file, when, and if the file was actually intact otherwise. You cannot verify that the voodoo code is actually valid.
So you should make sure that any [illegal] changes to the files will automatically invalidate the certificate (otherwise the method is useless).
Look, I don’t really know why you’re still posting. If you just wanted a quick, foolproof way to add comments to source code files, we’ve given you that.
and we still don't know what is your real goal. You can put whatever you want in your files. But why?
suppose uuencode did not exist and i was designing something to make it easy to include a binary file in email. would you still wonder why?
the idea is to be able to attach a small amount of data to a file that in the context of the file, does not affect the file, but can still be recognized as being there, extracted, decoded, (if needed), etc.
my desire at this point is to explore ways to look like comments in a large scope of programming languages. for example, one can begin a line with "#" in Bash or Python (and other languages) to make a comment.
suppose uuencode did not exist and i was designing something to make it easy to include a binary file in email. would you still wonder why?
But uuencode does exist, and if you were trying to reinvent it we'd tell you to use base64.
Now...
Are you being deliberately vague (to avoid revealing proprietary information, or because you don't want your idea stolen, or whatever), or is this actually how well-formed and specific your idea actually is?
(Earlier, I actually stopped myself from wondering out loud if you this was a scheme to hide your porn collection).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.