16
\$\begingroup\$

This is the cops' thread. The robbers' thread is here.

Your challenge is to write a program or function that, with a certain input, prints the exact string Hello, World! and a newline. Capitalization, spacing and punctuation must be exact.

Input may be taken via standard input, a file, or command-line/function arguments. Output may be given via return value, writing to a file, or standard output.

Your program must print Hello, World! for at least one input. When your program is given the wrong input (i.e. the input that does not make it print Hello, World!), it can do whatever you like - crash, print random nonsense, call Chuck Norris, etc.

You may not use a hashing algorithm or any similar methods of obscuring the required input.

Submissions are preferred to be runnable & crackable on TIO. Submissions not runnable or crackable on TIO are allowed, but please include instructions to download / run them.

After one week, this challenge will be closed to future cop submissions. The winner is the shortest code that is uncracked after a week of posting it ("it" being the code, not this challenge). The winner will be accepted after two weeks.

After a week has passed since posting, please mark your answer as safe and show the input (in a > ! spoiler quote). If a robber cracks your submission (before the week ends), please mark it as cracked and show the halting input (in a > ! spoiler quote).

Looking for uncracked submissions?

fetch("https://api.stackexchange.com/2.2/questions/137742/answers?order=desc&sort=activity&site=codegolf&filter=!.Fjs-H6J36vlFcdkRGfButLhYEngU&key=kAc8QIHB*IqJDUFcjEF1KA((&pagesize=100").then(x=>x.json()).then(data=>{var res = data.items.filter(i=>!i.body_markdown.toLowerCase().includes("cracked")).map(x=>{const matched = /^ ?##? ?(?:(?:(?:\[|<a href ?= ?".*?">)([^\]]+)(?:\]|<\/a>)(?:[\(\[][a-z0-9/:\.]+[\]\)])?)|([^, ]+)).*[^\d](\d+) ?\[?(?:(?:byte|block|codel)s?)(?:\](?:\(.+\))?)? ?(?:\(?(?!no[nt][ -]competing)\)?)?/gim.exec(x.body_markdown);if(!matched){return;}return {link: x.link, lang: matched[1] || matched[2], owner: x.owner}}).filter(Boolean).forEach(ans=>{var tr = document.createElement("tr");var add = (lang, link)=>{var td = document.createElement("td");var a = document.createElement("a");a.innerHTML = lang;a.href = link;td.appendChild(a);tr.appendChild(td);};add(ans.lang, ans.link);add(ans.owner.display_name, ans.owner.link);document.querySelector("tbody").appendChild(tr);});});
<html><body><h1>Uncracked Submissions</h1><table><thead><tr><th>Language</th><th>Author</th></tr></thead><tbody></tbody></table></body></html>

\$\endgroup\$
14
  • \$\begingroup\$ Very similar not a dupe though. \$\endgroup\$
    – Wheat Wizard
    Commented Aug 5, 2017 at 17:22
  • 13
    \$\begingroup\$ As I said in the sandbox, I feel that this is a duplicate of the halting question since any answer there could be posted here instead but with code for and infinite loop replaced with code to print hello world. I won't vote yet because I'd hammer, but I'm pretty convinced this is a dupe. \$\endgroup\$ Commented Aug 5, 2017 at 18:07
  • 5
    \$\begingroup\$ Obviously sha3 falls into that category, but otherwise where do you draw the line? I mean the mod 1e3 is also a hash function, and I'd even go so far and argue that many of the submissions are going to be hash functions, as this challenge is basically asking for such. \$\endgroup\$
    – flawr
    Commented Aug 5, 2017 at 21:52
  • 1
    \$\begingroup\$ Based on the answers I've seen in the past day, nothing has appeared that convinces me this isn't a duplicate. I'm going to close the cop challenge for now, and if the community disagrees it can be reopened, and if the community agrees they can close the robber thread too. \$\endgroup\$ Commented Aug 6, 2017 at 13:30
  • 1
    \$\begingroup\$ @Dopapp this has already been discussed, here (some comments deleted) and in chat. Answers cannot be copy-pasted, nor very easily ported, from that challenge to this one, so they are not duplicates. \$\endgroup\$
    – MD XF
    Commented Aug 6, 2017 at 17:49

35 Answers 35

1
2
2
\$\begingroup\$

CJam, 130 bytes (safe)

q'p/{'s/{{"cjaei"#}%{)},{`}%S*}%']*}%'[*~]Y8#,:Y;0a\{{__a#{\{_T=}{1$E}w\;}{"T(:T; _T=co T)
:T)0e] _T=)Y=T\t _T=(Y=T\t"S/=~}?}/}:E~;

Try it online!

This is split across two lines for clarity; the newline is not included.

This is semi-golfed, which makes it that much harder to understand.

There are an infinite number of solutions here. If anybody wants to try and find one, I wish them good luck...

Solution:

aipeepceeaiaeeeaeeeccsiiiiaesnccccjccccijcjjccejccccjaajaaaijcjeeejaajaijcccccej

\$\endgroup\$
2
  • \$\begingroup\$ How are inputs fed into the function? I tried to feed in some inputs (via arguments and input) but no output whatsoever. \$\endgroup\$
    – Voile
    Commented Aug 10, 2017 at 7:47
  • \$\begingroup\$ @Voile Inputs are read via STDIN. And yes, most inputs won't produce any visible output. \$\endgroup\$ Commented Aug 10, 2017 at 18:04
1
\$\begingroup\$

C (gcc), 80 bytes, Cracked

#define O(c)(((char**)v)+c)
#define W(c)*(O(c)-**O(2)+x)
main(x,v){puts(W(42));}

Try it online!

Provide command line arguments for the desired output.

The intended input commandline was:

"Hello, World!" ,

Quick explanation:

The program does some pointer arithmetics on argv[], using the first char of the second argument and the argument count. See the robbers' post for a full explanation. There are other solutions possible, but the one over there is the most simple one.

Important: This won't work when e.g. built for amd64, therefore the compiler switch -m32 on tio.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – ArchDelacy
    Commented Aug 7, 2017 at 22:39
1
\$\begingroup\$

Perl 5, 23 bytes (Cracked)

eval<>;END{print$x='x'}

Usage: takes one line of input of stdin and evals it. The END block keeps simple attempts like print"Hello, World!\n";exit from working.

Try it Online!

our $x;package X;require Tie::Scalar;@ISA=qw(Tie::Scalar);sub TIESCALAR{my$v;return bless\$v,'X';}sub STORE{}sub FETCH{return "Hello, World!\n"}tie $x,'X';

\$\endgroup\$
1
1
\$\begingroup\$

6502 machine code (C64), 94 bytes (Cracked)

00 C0 20 FD AE 20 9E AD 20 A3 B6 A0 00 B9 25 C0 C0 01 F0 21 C0 07 F0 1D C0 0B
F0 19 20 20 C0 C8 D0 EB 51 22 4C D2 FF F0 48 FA A2 1C 6D 72 30 06 A9 03 48 7C
A3 8D 48 C0 B9 26 C0 8D 45 C0 B9 27 C0 8D 46 C0 A2 00 BD FD AE 49 23 20 20 C0
C8 E8 E0 03 D0 F2 C0 0E D0 B5 49 1A 8D 18 D0 60

Disassembled:

00 C0       .WORD $C000       ; load address
20 FD AE    JSR $AEFD
20 9E AD    JSR $AD9E
20 A3 B6    JSR $B6A3
A0 00       LDY #$00
B9 25 C0    LDA $C025,Y
C0 01       CPY #$01
F0 21       BEQ $C033
C0 07       CPY #$07
F0 1D       BEQ $C033
C0 0B       CPY #$0B
F0 19       BEQ $C033
20 20 C0    JSR $C020
C8          INY
D0 EB       BNE $C00B
51 22       EOR ($22),Y
4C D2 FF    JMP $FFD2
F0 48       BEQ $C06F
FA          .BYTE $FA
A2 1C       LDX #$1C
6D 72 30    ADC $3072
06 A9       ASL $A9
03          .BYTE $03
48          PHA
7C A3       .WORD $A37C
8D 48 C0    STA $C048
B9 26 C0    LDA $C026,Y
8D 45 C0    STA $C045
B9 27 C0    LDA $C027,Y
8D 46 C0    STA $C046
A2 00       LDX #$00
BD FD AE    LDA $AEFD,X
49 23       EOR #$23
20 20 C0    JSR $C020
C8          INY
E8          INX
E0 03       CPX #$03
D0 F2       BNE $C044
C0 0E       CPY #$0E
D0 B5       BNE $C00B
49 1A       EOR #$1A
8D 18 D0    STA $D018
60          RTS

Online demo

Important: When load from disk (like in this online demo), the program only works after issuing a NEW command! Without first doing NEW, you'd only ever get an ?OUT OF MEMORY ERROR when trying to pass a string.


Usage: SYS49152,"[string]", where [string] is your input string.

Yes, input is a string this time, and the white area in the screenshot below doesn't tell you anything about the required length.

Screenshot

This should be quite hard to crack, but it's possible calculating everything back, no hashes or similar involved ;) You might need some reference for the C64 ROMs though. Further tip: look for an area only containing data in the disassembly listing :)

Like with my previous entry, here's a BASIC loader to paste into vice, just RUN this and the program is placed at $C000:

0fOa=49152to49243:rEb:pOa,b:nE
1dA32,253,174,32,158,173,32,163,182,160,0,185,37,192,192,1,240,33,192,7,240,29
2dA192,11,240,25,32,32,192,200,208,235,81,34,76,210,255,240,72,250,162,28,109
3dA114,48,6,169,3,72,124,163,141,72,192,185,38,192,141,69,192,185,39,192,141,70
4dA192,162,0,189,253,174,73,35,32,32,192,200,232,224,3,208,242,192,14,208,181
5dA73,26,141,24,208,96

Solution:

8bitsareenough

Explanation:

The code basically uses an XOR key of the same length as Hello, World!\n. As this would be quite simple to crack, the key isn't placed in the code as is but there are 3 times 3 bytes that are calculated from the C64's ROMs.

The 3 times 3 bytes in the data are in the format <key>, <low>, <high>, where <low>, <high> is the start address of 3 bytes in the ROM that are taken as part of our XOR key after XOR'ing them with <key>.

It's possible to crack it with some reference / disassembly to the C64 ROMs. Of course, it's easier to just try and get the key from the running program. I attempted to prevent the easiest method of doing this (just entering "Hello, World!\n", as XOR is reversed with the same key) by forcing a crash on wrong input. The crack linked cleverly modified the program, so it won't crash.

Another nice possibility to crack this would have been to spot the single place where output happens: EOR ($22),Y; JMP $FFD2. If you know that fetching a string using the BASIC routines will place a pointer to that string in $22/$23, all you have to do is set a breakpoint at EOR ($22),Y and get the XOR key delivered in the accumulator byte by byte.

\$\endgroup\$
2
  • \$\begingroup\$ And cracked again. This is good fun! \$\endgroup\$
    – A Gold Man
    Commented Aug 15, 2017 at 7:08
  • \$\begingroup\$ So, unfortunately, I have to give up on this. I could come up with an even harder-to-crack one but 1.) this would increase byte count and 2.) it's too late anyways. Nice job! \$\endgroup\$ Commented Aug 15, 2017 at 7:33
0
\$\begingroup\$

PHP, 94 bytes, Cracked

<?=constant(explode(',',$argv[1])[0]."::".explode(',',$argv[1])[1])==262144?"Hello, world
":a;

Try it online! First codegolf submission, feel free to help me improve this

Cracked, intended input :

ReflectionFunction,IS_DEPRECATED

Because

ReflectionFunction::IS_DEPRECATED = 262144

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$
    – nickb
    Commented Aug 7, 2017 at 12:13
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.