New filters on the Home Feed, take a look!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

3
What is the message digest (SHA2, etc.) of a number?
Post Flair (click to view more posts with a particular flair)
Post Body

How would you go about passing a numeric value to a secure cryptographic hashing algorithm like MD5, SHA2, etc.? From what I can tell they're only ever meant to handle a series of bytes. Would you convert say, an unsigned integer an array of bytes? What about signed integers? Floating points? Or would you just leave that as an exercise for the user to convert a number to bytes and then hash that?

Edit: Sorry I wasn't clear. I was just trying to be vaguely non-specific. I assure you I'm not lost. I'm the proprietor of the Euphoria programming language. Here's my problem: our built-in "hash" function is currently just a few checksum algorithms (Hsieh-32, Adler-32, and Fletcher-32) but it does currently support any data type by way of type punning integers and atoms (doubles) into bytes via unions, and by traversing nested sequences (arrays) using recursion. Frankly it's awful and I hate it. I want to implement actual cryptographic hashing algorithms like MD5, SHA2, etc. (yes, they're not all secure, sorry. corrected above.) but first I want to validate that I'm not crazy: hashing algorithms should just process byte arrays and let the user take whatever measures they want to convert non-byte data into bytes first (which we do have functions for) if necessary.

Author
Account Strength
100%
Account Age
8 years
Verified Email
Yes
Verified Flair
No
Total Karma
40,483
Link Karma
2,029
Comment Karma
36,514
Profile updated: 3 days ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago