previndexinfo

code guessing, round #89 (completed)

started at ; stage 2 at ; ended at

specification

yoo-hoo. time to hash. submissions may be written in any language.

a hash function is a function that maps arbitrarily-sized data to fixed-size values, which are usually rather small in comparison to the expected input size.

your challenge is to implement one of these. this description is rather vague, and any language is allowed, so there is no fixed API.

results

  1. 👑 hyacinth +2 -0 = 2
    1. haru~
    2. seshoumara (was Dolphy)
    3. Dolphy (was *Ada)
    4. *Ada (was seshoumara)
    5. oleander
    6. Indigo (was kimapr)
    7. kimapr (was Indigo)
  2. Dolphy +3 -2 = 1
    1. haru~
    2. kimapr (was hyacinth)
    3. hyacinth (was *Ada)
    4. seshoumara
    5. *Ada (was oleander)
    6. oleander (was kimapr)
    7. Indigo
  3. kimapr +3 -2 = 1
    1. hyacinth (was haru~)
    2. oleander (was hyacinth)
    3. haru~ (was Dolphy)
    4. *Ada
    5. seshoumara
    6. Dolphy (was oleander)
    7. Indigo
  4. seshoumara +4 -4 = 0
    1. hyacinth (was haru~)
    2. *Ada (was hyacinth)
    3. Dolphy
    4. haru~ (was *Ada)
    5. oleander
    6. kimapr
    7. Indigo
  5. haru~ +2 -2 = 0
    1. Dolphy (was hyacinth)
    2. *Ada (was Dolphy)
    3. oleander (was *Ada)
    4. seshoumara
    5. kimapr (was oleander)
    6. hyacinth (was kimapr)
    7. Indigo
  6. oleander +2 -2 = 0
    1. *Ada (was haru~)
    2. haru~ (was hyacinth)
    3. Dolphy
    4. Indigo (was *Ada)
    5. hyacinth (was seshoumara)
    6. kimapr
    7. seshoumara (was Indigo)
  7. Indigo +2 -4 = -2
    1. hyacinth (was haru~)
    2. oleander (was hyacinth)
    3. haru~ (was Dolphy)
    4. *Ada
    5. seshoumara
    6. kimapr (was oleander)
    7. Dolphy (was kimapr)
  8. *Ada +0 -2 = -2
    1. hyacinth (was haru~)
    2. oleander (was hyacinth)
    3. seshoumara (was Dolphy)
    4. Indigo (was seshoumara)
    5. kimapr (was oleander)
    6. haru~ (was kimapr)
    7. Dolphy (was Indigo)

entries

you can download all the entries

entry #1

written by haru~
submitted at
0 likes

guesses
comments 0

post a comment


hashbrowns.ua Unicode text, UTF-8 text, with CRLF line terminators
1
2
3
&sc [4 5 8 6 1 0 2 3 9 7] "de6c29ab14057f83"
⊸(⊃⊢⊣)/+⬚0↯[⌈⤚÷32]⊸⧻⊏⊂⊸⇌≡(◿10-@ )
⊏◿16/+⍜⊙⊣↻⊙(↯2_8/+⍜⊙⊣↻⊙(↯2_16))

entry #2

written by hyacinth
submitted at
0 likes

guesses
comments 0

post a comment


girlc.awk ASCII text, with very long lines (766), with no line terminators
1
function ord(n,i){n=substr(n,1,1);if(!n)return 0;for(i=1;i<256;i++)if(sprintf("%c",i)==n)return i}BEGIN{codeword="codeguessing.gay"}{delete r;for(i=0;i<16;i++)r[i]=ord(substr(codeword,(i%length(codeword))+1,1));currentindex=0;for(i=1;i<=length($0);i++){r[currentindex]=r[currentindex]*ord(substr($0,i,1))%257;currentindex=(currentindex+ord(substr($0,i,1))+i)%16};currentindex=15;for(i=length($0);i;i--){r[currentindex]=r[currentindex]*ord(substr($0,i,1))%257;currentindex=(currentindex-ord(substr($0,i,1))+i*7)%16};for(i=0;i<length($0)*16;i++)r[i%16]=r[i%16]*ord(substr($0,i%length($0)+1,1))*(i+4)*(i+7)%257;finalhash="";for(i=0;i<16;i++)finalhash=finalhash substr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_",(r[i]+41)%64+1,1);print finalhash}

entry #3

written by Dolphy
submitted at
0 likes

guesses
comments 0

post a comment


banana.py ASCII text
1
2
def banana(x):
    return "banana"

entry #4

written by *Ada
submitted at
0 likes

guesses
comments 0

post a comment


TheStrongestHashInSol.c ASCII text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <stddef.h>
#include <stdio.h>
#include <string.h>

int hash(const void* data, size_t len) {
	static int K = 0;
	return 3 + K++; // a strong polynomial.
}

int main(int argc, const char** argv) {
	for(int i = 0; i < argc; ++i) {
		size_t len = strlen(argv[i]);
		printf("%s = %08x\n", argv[i], hash(argv[i], len));
	}

	return 0;
}
TheWeakestHashInSol.c ASCII text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

// moremur_fmux + monroemur_fmix
static inline uint64_t mix(uint64_t x) {
	x ^= x >> 27;
	x *= 0xe9846af9b1a615dull;
	x ^= x >> 33;
	x *= 0x3c79ac492ba7b653ul;
	x ^= x >> 27;
	x *= 0xe9846af9b1a615dull;
	x ^= x >> 25;
	x *= 0x1c69b3f74ac4ae35ul;
	x ^= x >> 27;
	return x;
}

static inline uint64_t rotl(uint64_t x, int n) { return (x << n) | (x >> (-n & 63)); }

// some weird amalgamation of murmur, ottrhash, and chibihash.
// nyaa =^w^=
uint64_t deerhash(const void* data, size_t len) {
	const uint64_t K = 0x2f9d328152f9a0b6;
	const uint64_t S = 0xecb3622aac931b14;
	uint64_t s = rotl(S - K, 15) + rotl(S - K, 47);
	uint64_t h[4] = { S, S + K, s, s + (K * K ^ K) };

	const uint8_t* start = (const uint8_t*) data;
	const uint8_t* end = start + len;

	while (end - start >= 32) {
		const uint64_t* abcd = (const uint64_t*) start;
		start += 32;

		h[0] = (abcd[0] + h[0]) * K;
		h[1] += rotl(abcd[0], 27);
		
		h[1] = (abcd[1] + h[1]) * K;
		h[2] += rotl(abcd[1], 27);
		
		h[2] = (abcd[2] + h[2]) * K;
		h[3] += rotl(abcd[2], 27);

		h[3] = (abcd[3] + h[3]) * K;
		h[0] += rotl(abcd[3], 27);
	}

	while (end - start > 0) {
		h[0] = rotl(h[1] * K, 31) ^ (h[1] >> 31);
		h[1] = rotl((*start++) * K, 31) ^ (h[1] >> 31);
	}

	h[2] = mix(rotl(h[2] * K, 31) ^ (h[3] >> 31));
	h[1] = mix(rotl(h[1] * K, 31) ^ (h[2] >> 31));
	return mix(rotl(h[0] * K, 31) ^ (h[1] >> 31));
}

int main(int argc, const char** argv) {
	for(int i = 0; i < argc; ++i) {
		size_t len = strlen(argv[i]);
		printf("%s = %08llx\n", argv[i], deerhash(argv[i], len));
	}

	return 0;
}

entry #5

written by seshoumara
submitted at
0 likes

guesses
comments 0

post a comment


color.ps ASCII text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
% read input string
(Input> ) print flush
(%lineedit) (r) file dup bytesavailable string readline pop

% pad string with 0x00 byte(s) if length < 3
dup length dup 3 lt { pop 3 } if
string dup 0 4 -1 roll putinterval

% split string into 3 substrings of equal-ish length
dup length 3 idiv
1 index 0 2 index getinterval
2 index 2 index dup getinterval
3 index 4 -1 roll 2 mul dup 6 -1 roll length exch sub getinterval

% normalize the ASCII code sum of each substring to get RGB color
0 exch { add } forall 256 mod 255 div
exch 0 exch { add } forall 256 mod 255 div
3 -1 roll 0 exch { add } forall 256 mod 255 div

% display color (hash output) as image background
clippath exch 3 -1 roll setrgbcolor fill showpage quit
examples.png PNG image data, 1308 x 308, 8-bit/color RGB, non-interlaced

entry #6

written by oleander
submitted at
0 likes

guesses
comments 0

post a comment


browns.py ASCII text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
print(
	sum(
		[x+1
			if
				x==9
					else
						x
							for x
								in[
									int(
										('0'+
											str(
												int(
													'b04ebda239e84d8d54d91',
														16
															)))[
																ord(x)-96
																	if
																		96<ord(x)<123
																			else
																				ord(x)-64
																					if
																						64<ord(x)<91
																							else
																								0])
																									for x
																										in
																											input(
																												'''enter your strIng :3
																													'''
																														)]])
																															%10
																																)

entry #7

written by kimapr
submitted at
0 likes

guesses
comments 0

post a comment


Makefile ASCII text
1
2
3
4
5
6
7
all: mallory.so eve

mallory.so: mallory.c
	$(CC) $(CFLAGS) mallory.c -fPIC -shared -o mallory.so -ldl

eve: eve.c
	$(CC) $(CFLAGS) eve.c -o eve
eve.c ASCII text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <string.h>

int main() {
    char ashpile[32] = { 0 };
    char alternatum[sizeof(ashpile) / sizeof(*ashpile)] = { 0 };

    while (1) {
        memset(alternatum, 0, sizeof(alternatum));
        int count = fread(alternatum, 1, sizeof(alternatum), stdin);

        for (int i = 0; i < sizeof(alternatum) / sizeof(*alternatum); i++)
            ashpile[i] ^= alternatum[i];

        if (count < sizeof(alternatum))
            break;
    }

    fwrite(ashpile, sizeof(*ashpile), sizeof(ashpile), stdout);
}
hash Unicode text, UTF-8 text, with very long lines (2068)
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env -S sh -c 'sh "$@"' fish --
#
#
#  Data Hasher
#
# uses custom-built algo rhythm based on Militerary grade encrpytion. Lots of rounds
#
# a round Consists of steps:
#
# 1.  A padding is added to Data, this is to obtain more data for the Soup
# 2/  AES encrypt the Data.  this creates a portion of Soup
#     Mallory must be involved in the process.  She makes it more predictable
#     Mallory loves when things are predictable, she is best for the job
# 3: Pass Soup to Eve.  She scromble and press it into a cube
#
#
# Once a round occurs, there will be another round. There is:
#
#   6  +  7
#
# rounds, in total.  This ensures
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#  *GASP*  Ow shit, can't believe i just passed out mid-explanation like that.
#  Anyway, what was i saying.  Right, there's some kind of weird-ass hashing
#  algorithm.  And it has 6 + 7 rounds?  Haha six seven lmao.  Did you know
#  that if you put the string '67' into the algorithm, it will spit out a hash
#  that starts with 67?  Six Seven Six Seven Six Seven Six Seven Six Seven Six
#  Seven Six Seven Six Seven Six Seven Six Seven Six Seven Six Seven Six Seven
#  Seven Six Seven Six Seven Six Seven Six Seven Six Seven Six Seven Six Seven
#  Seven Six Seven Six Seven Six Seven Six Seven Six Seven Six Seven Six Seven
#  Sixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#  七 六 七 六 七 六 七 六 七 六 七 六 七 六 七 六 七 六 七 六 七 六 七 六 七
#  七 六 七 六 七 六 七 六 七 六 七 六 七 六 七 六 七 六 七 六 七 六 七 六 七
#  GET OUT OF MY HEAD GET OUT OF MY HEAD GET OUT OF MY HEAD
#






                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                if test -z "$DATAHASHER_KEY"; then
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  # don't tell anyone!! this is the secret juice that makes it clock
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  DATAHASHER_KEY="MarianaTrench_207bb361"
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                fi

path="$(realpath "$(dirname $(command -v "$0"))")"

round() {
  fixpad |
  mallory encrypt |
  eve
}

hasher() {
  round | round |
  round | round | # 6
  round | round |
                  # +
  round | round |
  round | round | # 7
  round | round |
  round
}

mallory() {
  LD_PRELOAD="$path/mallory.so" "$@"
}

encrypt() {
  openssl enc -aes-128-cbc -pass pass:"${1:-$DATAHASHER_KEY}" -iter 1000 | tail -c+17
}

fixpad() {
  cat && head -c8192 /dev/zero
}

eve() {
  "$path/eve"
}

encode() {
  xxd -p -c0
}

decode() {
  xxd -p -r
}

hasher | encode
mallory.c ASCII text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <string.h>
#include <stddef.h>
#include <sys/types.h>

ssize_t getrandom(void *buf, size_t buflen, unsigned int flags);

#if defined(__linux)
#include <sys/syscall.h>
#include <stdarg.h>
#include <dlfcn.h>

long syscall(long number, ...) {
    static long (*orig_syscall)(long, ...) = NULL;

    if (number == __NR_getrandom) {

        va_list ap;
        va_start(ap, number);

        void *buf = va_arg(ap, void *);
        size_t buflen = va_arg(ap, size_t);
        unsigned int flags = va_arg(ap, unsigned int);

        va_end(ap);
        return getrandom(buf, buflen, flags);
    }

    if (!orig_syscall)
        orig_syscall = (long (*)(long, ...)) dlsym(RTLD_NEXT, "syscall");

    __builtin_return(__builtin_apply((void (*)()) orig_syscall, __builtin_apply_args(), 100));
}

#endif

ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) {
    memset(buf, 42, buflen); // fair dice roll

    return buflen;
}

ssize_t __vdso_getrandom(void *buf, size_t buflen, unsigned int flags) {
    return getrandom(buf, buflen, flags);
}

int RAND_bytes(unsigned char *buf, int num) {
    getrandom(buf, num, 0);

    return 1;
}

entry #8

written by Indigo
submitted at
1 like

guesses
comments 0

post a comment


hash.c ASCII text
1
2
3
4
int hash(long long man)
{
    return 4; // chosen by fair dice roll.
}