Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Suppose I have 8 bits. Then total possible combinations would be 2^8 . Is there some encryption technique I could use so that I can identify all those 256 numbers with less bits ( say 5 or 6 bits). I know this is kind of hard ( and impossible ) . But if someone could help.
No, this is not possible.
At least 2 of the original 256 states would be mapped to the same encoded state. Therefore you cannot reconstruct the original stated from the encoded state.
see Pigeonhole principle
According to the pigeonhole principle there's no there's no way to stuff 8 bits of information in 5 or 6 without loss of data.
With larger sets of data you can use lossless compression techniques to reduce the amount of data needed, but those techniques have overhead that would take more information than could be saved from just 8 bits.
The only way you can compress 8 bits is to restrict the data set so that patterns can be encoded. e.g. if exactly one of the first two bits can be 1 then you can "encode" that to save one bit, but that limits the number possible values to
2^7.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
As the title says, is it possible?
No, this isn’t possible. There are several ways you can encode “the set of all prime numbers” as a language, and the standard ways of doing so (writing the number out in binary, writing out a number of tally marks equal to the number, etc.) aren’t regular.
Formally proving this is a bit tricky but is doable using either the pumping lemma for regular languages or the Myhill-Nerode theorem. The crux of the arguments boil down to the fact that replicating parts of prime numbers repeatedly will eventually give you a non-prime number, and that’s where the technical details of the proofs come in.
Hope this helps!
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
What would be the most space efficient way to encrypt some data such that the encrypted data satisfies any one of the following constraints:
1) Fits in 32 bytes or less of hexidecimal (64 characters)
2) Fits in 28 bytes or less utf-8 characters (28 characters)
3) Fits in a 64 bit unsigned integer
The goal is to encrypt some data (like user id + nonce) and store it publicly on a blockchain and then decrypt it later on a server. The storage requirements of the blockchain I'm using (Stellar memos -- https://www.stellar.org/developers/guides/concepts/transactions.html#memo).
I'm looking for space-efficient encryption algorithms, or some combination of encryption + lossless compression that could make it fit.
There will be two inputs to encrypt: a user id and a nonce -- let's just assume we can fit both inside of 25 characters.
Example:
encrypt("7863439|12343567") -> "385acd1ca0ab619b9f832025fa358b69"
decrypt("385acd1ca0ab619b9f832025fa358b69") -> "7863439|12343567"
Use AES-256 or Twofish-256 You will have 256 bit = 32 bytes. This fits your 1st requirement. Both are space efficient. Well it depends of course how you define "efficient".
Maybe you could use hashing instead of encryption. Hash your data and store it on a server. Finding input data that will collide with your stored hash is designed to be difficult. Use a strong hashing algorithm that outputs 32 bytes of data, and you're done.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Suppose im given a large essay. Whats the best method available to shrink it down into a small string of letters which I can decode later? Suppose Im allowed to keep a set of predefined keys if i need to?
Assuming the text is English and you want to minimize the size of the "small string", you will find a number of algorithms here: http://www.maximumcompression.com/data/text.php
For ease-of-implementation, however, you might simply want to use zlib, as it's generally available.
Further, if you want to encrypt the compressed text, you should use AES in CTR mode (and possibly appending an HMAC; ref: http://www.daemonology.net/blog/2009-06-11-cryptographic-right-answers.html).
Finally, assuming that by "asring of letters" you meant "a string of letters", you could base-64 encode the encrypted data, which would give you a string of letters, numbers, and a limited amount of punctuation.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm a total beginner to encryption and I don't really understand anything about it.
Let's say I had a file TOPSECRET.BIN. What if I just:
read file byte by byte
XOR each byte by 69
write "encrypted" data back into file
Sure it's simple, but how is anyone ever going to know how to decrypt that?
The main problem is that your ciphered text will still exhibit the hierarchical structure of the cleartext. So if the cleartext was english text, the same hierarchical structure you see in the english phrases will be in the ciphered message.
If you XOR each byte with 69, figuring it out will be as simple as just trying 256 bytes to XOR. Plus language structure can be used for cryptanalysis.
You can use XOR for perfect encryption, though. Just choose a random sequence of bytes with length equal to your text and XOR it byte by byte. The random bytes will be your key. However, it will be as hard to communicate this key securely as it would be the message itself. And if you reuse this key, it would be easy enough to analyze multiple encrypted messages to figure it out.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I had read someone's blog that the high precision random number is hard to get, he said if we want to get a chance in a million, using :
Random(1,1000)*Random(1,1000) < 2 is better than Random(1,1000000)<2
( we suppose Random(1,n) generate integer numbers between 1 to n )
theoretically, the probilities of two are the same, but what's different action of those expression in a real program? for example rand() function in standard C language, and please give more information.
What you probably want by asking for 'high-precision' is a cryptographically secure pseudorandom number generator, that is, one with a high enough entropy that it's certifiably random enough for high security applications. LavaRnd is one of these, if you provide it with a lens capped webcam (ideally a webcam in a box completely devoid of light) for input.
Another cryptographically sound algorithm is Blum-Blum-Shub, but it's very slow. You could also take a look at Fortuna.