PDA

View Full Version : calculating sha256


Amet
2009-09-05, 16:39
Hi,

I need to use sha256 in my script.

can someone tell me if it is available in XBMC python.I see that hashlib is not available and I found sha.so but the results are not sha256.

any help is appreciated.

TIA

Zeljko

althekiller
2009-09-05, 19:17
See wikipedia, implement it. That series isn't terribly difficult IIRC.

Amet
2009-09-05, 21:14
which module would I need to import since hashlib is not available and sha doesnt have the sha256?

Thanks
Zeljko

Dan Dare
2009-09-06, 18:30
I don't know if this is much help, see at the top a library for Python 2.4 for Windows...

http://code.krypto.org/python/hashlib/

Amet
2009-09-06, 18:41
I don't know if this is much help, see at the top a library for Python 2.4 for Windows...

http://code.krypto.org/python/hashlib/

Thanks Dan,

I have tried that already and it needs to be installed. I cant just import it because it has dependencies.

I have created php script on my web server to calculate sha256.The third service in subtitle script, podnapisi.net, needs the hashed password.

Regards
Zeljko

Dan Dare
2009-09-06, 21:54
Sorry thats all I could find.

Maybe they could write a web service method to do just that, others might want to use it as well in their implementations, although they might say it defeats the original purpose, although wouldn't be completely un-secure as you would only need to send the password on it's own or in something like MD5, dunno, throwing ideas here.

Alternatively, maybe find some C++ code and push an enhancement request with XBMC for a built-in or HTTP API function...

I guess both would take time, your solution is probably fine, as long as you don't collect the passwords, users won't mind :)

Amet
2009-09-06, 22:17
Sorry thats all I could find.

Maybe they could write a web service method to do just that, others might want to use it as well in their implementations, although they might say it defeats the original purpose, although wouldn't be completely un-secure as you would only need to send the password on it's own or in something like MD5, dunno, throwing ideas here.

Alternatively, maybe find some C++ code and push an enhancement request with XBMC for a built-in or HTTP API function...

I guess both would take time, your solution is probably fine, as long as you don't collect the passwords, users won't mind :)

Hi Dan,

Thanks for trying :)

this is whats needed for the password

formattedPassword = SHA256(MD5(clearPassword) + randomNonce)

randomNonce is a random string from the podnapisi.net retrieved every time when initialized.

the only function I cant do in python 2.4 is SHA256, so the script sends md5 of the clear password + randomnonce to the server and gets sha256 as a result.That result is than used as password to authorize at their servers alongside with the username.


Its not like I have any use for the passwords for free subtitle download site, and without username as well.Users are not forced to use the service. There are two more. :)

I am still doing some research on this before releasing the updated script. but it doesn't seem possible with just python 2.4


Zeljko

Voinage
2009-09-20, 03:42
Use pycrypto.

http://www.dlitz.net/software/pycrypto/doc/

If you want the pre-compiled python 2.4 just download the ninja video plugin from my google code page and take the crypto folder.

It handles sha without a problem.

Cheers Vin.

Amet
2009-09-20, 10:42
Use pycrypto.

http://www.dlitz.net/software/pycrypto/doc/

If you want the pre-compiled python 2.4 just download the ninja video plugin from my google code page and take the crypto folder.

It handles sha without a problem.

Cheers Vin.

Thanks!

I have it sorted out already, but I will have a look. It might be a better solution.

Cheers
Zeljko