Score:1

Encrypting long messages to the same length keys

in flag

I am looking for a simple encryption of the text messages and in order to save some bandwidth, storage etc, I was looking to encrypt them into the same length strings. Something similar to how youtube is doing for their video ids. Having billions of videos in their database, they manage to encode them with only couple of letters and digits.

Is there any encryption which can output the same length string for lets say 1 to 1000 characters message?

To simplify the question with an example:

Users message -> "Hello" -> encrypts to -> "33j48dus9"
Users message -> "Hello my name is Jeff..." -> encrypts to -> "34j4fd3s9"
Ievgeni avatar
cn flag
Is the size of your text messages bounded? If not you can't hope have a constant-size for information-theoretical reason.
SAI Peregrinus avatar
si flag
I think you want to look up the difference between a hash function (what Youtube is using) and encryption. Youtube is NOT encrypting the video ID, they're storing the entire name (and video) and the ID, and the URL points to the ID. Then the server just looks up the corresponding ID in the database and gets the rest of the information.
SAI Peregrinus avatar
si flag
To possibly correct my previous comment: the video ID may not actually be generated by hashing anything, it's likely just a randomly generated ID. The database generates a new ID for each video uploaded, with some sort of system to ensure there are no duplicates. It's probably internally just some sort of hashed counter, but could be as simple as randomly generating an ID, checking if it exists, and if so trying again until a new ID is generated. https://stackoverflow.com/questions/3034861/youtube-url-algorithm
Red Sun avatar
us flag
This looks like a reversible hash function. It is possible but I have to say that YouTube is not encrypting its video, its generating a random ID or hashing the video.
AlwaysConfused avatar
in flag
Even the hashing would do. I mean it depends how secure it is as I dont want to encrypt to a military grade security. Mainly its just the same length hash or encryption to output different length messages if thats even possible
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.