Score:0

Is there a hash function that is semi-two-way?

us flag

I am looking for a hash function that uses a timestamp as salt, and produces an output that when run through another function only returns the timestamp used.

What would this be called? It's not a one-way hash and it's not a fully reversible hash function.

Maarten Bodewes avatar
in flag
This might simply be encryption (as indicated by the now removed comment), where the salt is used as a key and the timestamp is used as plaintext.
us flag
That would require two separate encrypted messages, right? One for the timestamp (encrypted using salt as key), and one for the actual message (encrypted with PGP key using salt)? Is there a way to do it in one?
Maarten Bodewes avatar
in flag
Sorry, maybe you should try what you are trying to achieve. A salt/timestamp is commonly public knowledge, you can just include it with the ciphertext. So I don't get your question. Note that there is nothing about a message in your question.
us flag
I have `data = {"message":"testdata"}` that I want to encrypt. Using hashlib I'd do `import hashlib, salt="randomstr", digest = hashlib.pbkdf2_hmac('sha256', data, salt, 10000)`. Then I can check the hash output to see if the data is the same as the original file. Is there a function I could use on that same hash output that would expose the salt string? Is there a different library I should use?
Maarten Bodewes avatar
in flag
PBKDF2 is a one way function; you are not encrypting anything. PBKDF2 uses a password and a public salt to derive a key, which you can use to encrypt.
us flag
I know that. That was just an example. I don't know what function would be semi-two way and only reveal the salt. Learning that is the purpose of my question.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.