- Const-ified input parameter.
- Use non-reserved macro for the include guard.
- Use unsigned int buffer to avoid “left shift of
1236923897 by 8 places
cannot be represented in type int” reported by Clang’s
UndefinedBehaviorSanitizer.
* See RFC-4648. This implementation produces lowercase hex characters.
* Returns length of encoded string.
*/
-unsigned int base32hex(char *out, uint8_t *in, unsigned int len) {
+unsigned int base32hex(char *out, const uint8_t *in, unsigned int len) {
int buf = 0, bits = 0;
char *x = out;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _BASE32_HEX_H
-#define _BASE32_HEX_H
+#ifndef BASE32_HEX_H
+#define BASE32_HEX_H
#include <stdint.h>
-extern unsigned int base32hex(char *out, uint8_t *in, unsigned int len);
+extern unsigned int base32hex(char *out, const uint8_t *in, unsigned int len);
#endif