How can I reversibly compress a ciphertext? [closed] - encryption

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 months ago.
Improve this question
I am a Rust developer and I want to know how I can do the following:
Let's say, for example, I have a ciphertext (not a real one):
ddofjasf9dasdf=-6yoadfhasfh8adfsdfzsdfjnzsfh8adfsdfzsdfjnzf9dasdf=-fhasfh8adfsdfzsdfjnzsfh8adfsdfzsdfjnzf9dasdf6yoadfhaasf9dasdf=-p-dfhasfh8adfsdfzsdfjnzsfh8adfsdfzsdfjnzf9dasdf=-jasf9da.
How can I compress this in a way like a SHA256 hash and then convert it back to its original state? The reason I want to do this is that the ciphertexts I'm generating are pretty big and I want to reduce the size as much as possible.

How can I compress this in a way like a SHA256 hash and then convert it back to its original state?
You can't. A hash is not a compression. It is irreversible. Compression is things like deflate instead.
Also, encrypted data are mostly like random in that they cannot be really compressed, if anything you would need to compress before doing the encryption.

Related

How can I made a data encryption method? (SHA256, Base64, etc.) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I would love to make my own data encryption method like Base64 and such. (preferably in Python.)
Would it be secure if I assigned "a" to for say a random number between 1-100 and a random letter or such. (for example 53f) and other letters are combinations and its random. But then how would I make a decoder, sorry for the long question haha. Thanks!
Do not start by making your own encryption method. Start by reading Bruce Schneier's Memo to the Amateur Cipher Designer.
Then write your own versions of the simpler existing ciphers: Caesar, Vigenere, (both of historical interest) RC4, Feistel. That will help you with the structure of ciphers, particularly RC4 -- a stream cipher and Feistel -- a block cipher framework.
Base64 is not a cipher, as has been pointed out. It is a useful exercise to write your own Base64 encoder/decoder, though most modern languages include one in their library anyway. That exercise helps you practice bit manipulations.
When you have done all that, find an implementation of AES that you are happy using. Any cipher you devise will not be as secure as AES.

using cryptographichash in Qt [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am making a program in Qt5.2.1 and in it I am using a text file to store some data. I would like to encrypt it and decrypt it inside the program and display the text stored in the file in a QPlainTextEdit ( or any other similar widget).
I searched and came across Qcryptographichash but i have no idea how to use it. I read somewhere that it does not provide a very secure encryption but that doesn't matter ( I am not expecting hackers to try and read this file).
So, could anyone guide me in the right direction, maybe even give me some code. :D
QCryptographic hash creates a hash from given data. That is a one-way process, so the it will not do what you want, namely encrypt the data in a form that can be retrieved via decryption.
You can read more about the difference between encryption and hashes here.
You need to research into possible encryption algorithms. To my knowledge, that's not something that is part of Qt.
It's a large area of on-going research; there are so many to choose from, as you can see here.

Given an encrypted file, and a non-encrypted version of the same file, can the encryption key be easily recovered? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
This question is partly theoretical and partly practical. A perfect answer would answer theoretically why, and practically how.
Question
Given an encrypted file, and a non-encrypted version of the same file, can the encryption key be recovered? More specifically how might one achieve this?
Background
I have some backup files from a colleagues old machine. They have been stored in an encrypted 7zip file. The file table has not been encrypted, so it should be possible to isolate individual files. What I don't have is the actual encryption key (due to a storage medium failure). I do however have some unencrypted files which are also in the container. How can I use these to recover the whole archive?
As others have said, this is a "Known Plaintext Attack". All good cyphers are proof against such an attack. Any cypher which cannot withstand such an attack never gets off the starting blocks.
The best suggestion is to find out the specific encryption method used and look for specific weaknesses in that particular method. Alternatively, ask people who knew the key if they can remember even part of the original password. "It began with a D" will reduce the work you need to do to brute force it by a factor of 26 or 52.

what is HttpResponse.OutputStream Property in Asp.net? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I read Microsoft explanation about what is OutputStream Property! but i really don't understand what is this mean! someone can give me more explanation about this?
The OutputStream is mechanism by which you can transmit content to the client in binary form such as files. This contrasts with the Output property which enables text-based content to be sent to the client.
If you look at the MSDN documentation for both properties, you will see the OutputStream is an implementation of System.IO.Stream which enables you to work with objects as a sequence of bytes, which is usually the most efficient way of moving file content around in .NET. Output is an implementation of System.IO.TextWriter.

Whats the best way to shrink a large body of text? [closed]

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.

Resources