These functions seems to never have been checked in. Should I do that? Should they be named to_hex/from_hex, or string2hex/hex2string?
/ Niels Möller ()
Previous text:
2002-05-10 22:42: Subject: nettle.cmod
Getting down to the optimal number of classes, and making the best use of the hacks in nettle's nettle-meta.h.
But I may be able to solve the problem in a better way once I get inherit to work. At the moment, my problem is that aes->crypt dies of bus error...
And I've had to hack the String.from_hex and to_hex functions, as the GMP-versions didn't handle leading zeroes right. These are the current definitions. Do they look ok? I thought array_sscanf(s, "%@2x") would work, but appearantly sscanf doesn't support @.
/*! @decl string from_hex(string hex) *! *! Convert a string of hexadecimal digits to binary data. *! *! @seealso *! @[to_hex()] */ string from_hex(string s) { if (sizeof(s) % 2) error("Can't have an odd number of digits.");
return (string)(array_sscanf(s, "%{%2x%}")[0] * ({})); }
/*! @decl string to_hex(string hex) *! *! Convert a string of binary data to hexadecimal digits. *! *! @seealso *! @[from_hex()] */ string to_hex(string s) { return sprintf("%@02x", (array(int)) s); }
/ Niels Möller ()