LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   writing a few lines of comments that work in most languages (https://www.linuxquestions.org/questions/programming-9/writing-a-few-lines-of-comments-that-work-in-most-languages-4175723599/)

NevemTeve 04-17-2023 11:59 AM

If this is meant to prove authorship, then it won't work: anyone can add anything into a text-file.

dugan 04-17-2023 01:00 PM

I really hope that the “voodoo code” isn’t intended to be executeble. That would be a security nightmare.

Skaperen 04-19-2023 01:28 PM

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.

dugan 04-19-2023 04:54 PM

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.

pan64 04-20-2023 12:13 AM

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)

Skaperen 04-20-2023 05:02 PM

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).

astrogeek 04-20-2023 07:00 PM

Quote:

Originally Posted by Skaperen (Post 6426027)
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 (Post 6425251)
If this is meant to prove authorship, then it won't work: anyone can add anything into a text-file.


MadeInGermany 04-21-2023 12:17 AM

Quote:

Originally Posted by dugan (Post 6425775)
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.

pan64 04-21-2023 01:23 AM

Quote:

Originally Posted by Skaperen (Post 6426027)
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).

dugan 04-21-2023 09:06 AM

Quote:

Originally Posted by NevemTeve (Post 6422913)
Maybe you mean `signature`?

We now know the answer is yes. The stated use case is what GPG signatures are for.

And let’s be clear: “I need to add stuff to files and check that stuff later” is not a use case. “I need to prove authorship of a file” is.

https://www.techrepublic.com/article...inux-with-gpg/

Skaperen 04-21-2023 12:28 PM

Quote:

Originally Posted by dugan (Post 6426138)
We now know the answer is yes. The stated use case is what GPG signatures are for.

And let’s be clear: “I need to add stuff to files and check that stuff later” is not a use case. “I need to prove authorship of a file” is.

https://www.techrepublic.com/article...inux-with-gpg/

it can be that but it is not limited to that. it can be used for supplementary data.

dugan 04-21-2023 02:37 PM

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.

pan64 04-22-2023 04:29 AM

Quote:

Originally Posted by Skaperen (Post 6426181)
it can be that but it is not limited to that. it can be used for supplementary data.

and we still don't know what is your real goal. You can put whatever you want in your files. But why?

Skaperen 04-22-2023 06:14 PM

Quote:

Originally Posted by pan64 (Post 6426310)
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.

dugan 04-22-2023 07:02 PM

Quote:

Originally Posted by Skaperen (Post 6426411)
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).


All times are GMT -5. The time now is 06:34 PM.