despite its simplicity, for some reason, my code refuses to work, even though the encryption works

# add() is just (a+b)%2**32. for some reason, without the function, it doesnt work
delta = 0x9e3779b9
sum = 0xc6ef3720
for x in range(cycles):       # 32
	data[1] = add(-add(data[0]<<4, key[2]) ^ add(data[0], sum) ^ add(data[0]>>5, key[3]), data[1])
	data[0] = add(-add(data[1]<<4, key[0]) ^ add(data[1], sum) ^ add(data[1]>>5, key[1]), data[0])
	sum -= delta

can anyone tell me why?

Recommended Answers

All 2 Replies

What's key?
Avoid using sum since it is Python function, could get you into trouble later.

key is a 128 bit value, split into 4 32-bit values

i dont really thing sum causes any problems. the encryption part of if, which also uses sum works. besides, this is more or less the entire code. the rest of it is changing the values into hex and putting them together

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.