md5 for IronPython

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

md5 for IronPython

Seo Sanghyeon-3
md5 module is implemented as a C extension module in CPython. As this
is currently not included in IronPython, I wrote a tiny wrapper around
System.Security.Cryptography. Here it is in case you want it too.

http://sparcs.kaist.ac.kr/~tinuviel/devel/fepy/md5.py

It's under 30 lines!

It should be trivial to adapt this to other hash algorithms.

Seo Sanghyeon
_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Reply | Threaded
Open this post in threaded view
|

Re: md5 for IronPython

Shawn Farkas
If you wanted to easily extend it to other algorithms, then instead of using MD5.Create() in your __init__, you could instead do HashAlgorithm.Create("MD5").

That allows you to swap in any hash algorithm you'd like (and that the framework supports) just by swapping the string.

-Shawn

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Sanghyeon Seo
Sent: Thursday, January 26, 2006 2:55 AM
To: [hidden email]
Subject: [IronPython] md5 for IronPython

md5 module is implemented as a C extension module in CPython. As this
is currently not included in IronPython, I wrote a tiny wrapper around
System.Security.Cryptography. Here it is in case you want it too.

http://sparcs.kaist.ac.kr/~tinuviel/devel/fepy/md5.py

It's under 30 lines!

It should be trivial to adapt this to other hash algorithms.

Seo Sanghyeon
_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Reply | Threaded
Open this post in threaded view
|

Re: md5 for IronPython

Keith J. Farmer
In reply to this post by Seo Sanghyeon-3
Unless I'm lacking sleep and miss something (likely), you could make an
overload that took an enum, such as the pre-existing ones in the
framework.

-----
Keith J. Farmer // [hidden email]

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Shawn Farkas
Sent: Thursday, 26 January 2006 09:08

If you wanted to easily extend it to other algorithms, then instead of
using MD5.Create() in your __init__, you could instead do
HashAlgorithm.Create("MD5").

That allows you to swap in any hash algorithm you'd like (and that the
framework supports) just by swapping the string.

_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Reply | Threaded
Open this post in threaded view
|

Re: md5 for IronPython

Shawn Farkas
The reason we use a string is that it's actually a fully pluggable framework.  For instance, someone in the NSA could have a top-secret hash algorithm that we didn't put into the framework.  They could implement it themselves, register it in machine.config, and then do HashAlgorithm.Create("SuperSecretNSAHash") and it would work.

-Shawn

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Keith J. Farmer
Sent: Thursday, January 26, 2006 9:38 AM
To: Discussion of IronPython
Subject: Re: [IronPython] md5 for IronPython

Unless I'm lacking sleep and miss something (likely), you could make an
overload that took an enum, such as the pre-existing ones in the
framework.

-----
Keith J. Farmer // [hidden email]

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Shawn Farkas
Sent: Thursday, 26 January 2006 09:08

If you wanted to easily extend it to other algorithms, then instead of
using MD5.Create() in your __init__, you could instead do
HashAlgorithm.Create("MD5").

That allows you to swap in any hash algorithm you'd like (and that the
framework supports) just by swapping the string.

_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Reply | Threaded
Open this post in threaded view
|

Re: md5 for IronPython

Keith J. Farmer
Which is why I suggested an overload.  Enums protect against spelling mistakes that strings, while flexible, promote.  With an overload you can use either, preferring the enum for the compile-time assist (and as an indication that perhaps the user wants to use the framework implementation of SHA, for example).

________________________________

From: [hidden email] on behalf of Shawn Farkas
Sent: Thu 1/26/2006 9:43 AM
To: Discussion of IronPython
Subject: Re: [IronPython] md5 for IronPython



The reason we use a string is that it's actually a fully pluggable framework.  For instance, someone in the NSA could have a top-secret hash algorithm that we didn't put into the framework.  They could implement it themselves, register it in machine.config, and then do HashAlgorithm.Create("SuperSecretNSAHash") and it would work.

-Shawn

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Keith J. Farmer
Sent: Thursday, January 26, 2006 9:38 AM
To: Discussion of IronPython
Subject: Re: [IronPython] md5 for IronPython

Unless I'm lacking sleep and miss something (likely), you could make an
overload that took an enum, such as the pre-existing ones in the
framework.

-----
Keith J. Farmer // [hidden email]

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Shawn Farkas
Sent: Thursday, 26 January 2006 09:08

If you wanted to easily extend it to other algorithms, then instead of
using MD5.Create() in your __init__, you could instead do
HashAlgorithm.Create("MD5").

That allows you to swap in any hash algorithm you'd like (and that the
framework supports) just by swapping the string.

_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

winmail.dat (6K) Download Attachment