954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

tea decryption algorithm

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?

calccrypto
Light Poster
35 posts since Nov 2009
Reputation Points: 10
Solved Threads: 1
 

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

bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184
 

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

calccrypto
Light Poster
35 posts since Nov 2009
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You