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

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.

Related

how to determine the encryption that was used to encrypt string? [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 months ago.
Improve this question
i have two strings
9d14be68d71e15449d7ace056905429e28e319949eace8521c6114da6223208b37b32e50c045da86eccae39e2034ec14
3081d302010104205f20ff52fe5b542b2901408a1cbd4fb19b33b105a6f7e9e2bb36c64bae1e3fcaa08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220002000be91168a24103962a0a5e899a1ee557c52105770607b4b746e9f5da45427d
The first one is encrypted version of the second and the password is:
this sucks
So i want to find out the type of encryption that was used and how.
I will then use python to decrypt it as to experience cryptography on my own.
The above encryption was done by Bitcoin core app.
Some research say that the app uses AES CBC to encrypt the wallet data so extracted the data before and after encryption for this experiment.
How was the string encrypted?
Please bear with me i am still learning encryption.
There is no way of knowing. Maybe take a look at ciphertext indistinguishability.
Your best chance is to brute force the cypher with your python script. Keep in mind that there are a lot of well-known encryption algorithms (AES, 3DES, ...), key lengths, encryption modes (CBC, CFB, ...) and padding options so this might not be even possible due to high number of combinations.
Also, there is another problem. You password this sucks is shorter than the key size encryption algorithms use. For example, AES requires keys to be either 128, 192 or 256 bits of length so you need to make your password of that length. There is no way of knowing what key stretching technique (PBKDF2, bcrypt, scrypt, ...) or what hashing algorithm (SHA256, SHA512, ...) was used to achieve adequate key size.
This task is not impossible but highly improbable.

Number encryption algorithm [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 5 years ago.
Improve this question
I have a list of numbers. I will be calling a service(let's say accountant service) which is going to perform some operation on these list of numbers and will return me the final result.
I don't want to pass my data in plain format. I want to encrypt numbers in such a way if service performs any arithmetic operation and return me the result, I will be able to decrypt it back with actual result.
Yes. You can use something called Homomorphic encryption, which "is a form of encryption that allows computation on ciphertexts, generating an encrypted result which, when decrypted, matches the result of the operations as if they had been performed on the plaintext." With this type of encryption, they can be Partially homomorphic or Fully homomorphic. A fully homomorphic encryption can support arbitrary computation (also called "bignum arithmetic" or "Arbitrary-precision arithmetic"), whereas partially homomorphic algorithms cannot. As stated on the cryptography stack exchange by user mikeazo in this thread,
ElGamal is a semantically secure, multiplicativey homomorphic cipher. Paillier is a semantically secure, additively homomorphic cipher.
The user also elaborates further and mentions a significant downside of this form of encryption:
Homomorphic ciphers typically do not, in and of themselves, do not provide verifiable computing. In words, you encrypt your data, send it to the cloud and let the cloud compute on it for you. How do you know the cloud performed the correct computation? To get this sort of guarantee, other machinery is needed.
In your case, you would be sending it through an (I am assuming) reputable API, so this may not be a concern of yours.
From my research, your best bet will probably be Gentry's cryptosystem. To use this (in a program), HElib should work fine.
In the future, crypto.stackexchange.com would probably be a better place for this type of question

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.

Why is encryption so significant/difficult? [closed]

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.

Resources