redef class String
# returns the md5 digest of the receiver string
# algorithm implemented by L. Peter Deutsch <ghost@aladdin.com>
redef class String
# returns the md5 digest of the receiver string
# algorithm implemented by L. Peter Deutsch <ghost@aladdin.com>
- fun md5: String import String.to_cstring, NativeString.to_s `{
+ fun md5: String do return to_cstring.native_md5.to_s
+end
+
+redef class NativeString
+ private fun native_md5: NativeString `{
md5_finish(&state, digest);
for (di = 0; di < 16; ++di)
sprintf(hex_output + di * 2, "%02x", digest[di]);
hex_output[32] = '\0';
md5_finish(&state, digest);
for (di = 0; di < 16; ++di)
sprintf(hex_output + di * 2, "%02x", digest[di]);
hex_output[32] = '\0';