1
$\begingroup$

I'm very new to encryption and I wanted to know if it is secure or just possible to use encryption on single chars. I did some research, but nothing to clear and i'm a bit confused. The modes I think it is possible to do it with are one-time pad, RSA and AES in counter mode.

These are probably wrong ,but I have no idea why. So please explain me why these can't be used or maybe can be used.

EDIT: since I'm building a keylogger I could just buffer up and encrypt the whole buffer, encrypting a single char is not necessary.

$\endgroup$
  • 1
    $\begingroup$ One-time pads, RSA and AES-CTR are not used at all in the same way. They cannot be used interchangeably and are mostly useless in practice if used alone. $\endgroup$ – A. Hersean Jun 19 at 9:45
  • $\begingroup$ This question would be better suited on security.stackexchange.com. $\endgroup$ – A. Hersean Jun 19 at 9:46
  • 1
    $\begingroup$ What do you want to achieve and what you want to protect against? That is, what is the threat? What do you need to protect? What are the means of action of the threat? $\endgroup$ – A. Hersean Jun 19 at 9:48
  • $\begingroup$ I want to create a keylogger that encrypts the keys before logged. It is nothing that needs to be used professional. mainly a personal project to learn about encryption, but I want to know why things are not secure. $\endgroup$ – Dries Jans Jun 19 at 10:06
  • $\begingroup$ @DriesJans stream ciphers seems more appropriate $\endgroup$ – Natanael Jul 1 at 11:02
4
$\begingroup$

There is no minimal message size. Even an empty message can be securely encrypted, i.e. the ciphertext is indistinguishable from a different encrypted message, as long as the encryption key remains secret.

Can you describe exactly what are want to achieve?

Where will the secret key come from?

Even though minor optimizations are possible with very short messages (in particular, short tags may become acceptable), you should use traditional constructions. ChaCha20-Poly1305 and AES-GCM, in particular, don't require padding, and work with short messages just as well as with long messages.

Edit: since your use case is a key logger, you probably don't need to encrypt individual characters. Buffer them up to a reasonable size (maybe 1KB), and encrypt the buffer once it's full or when the application terminates.

$\endgroup$
  • $\begingroup$ I want to create a keylogger that encrypts the keys before logged. It is nothing that needs to be used professional. mainly a personal project to learn about encryption, but I want to know why things are not secure. $\endgroup$ – Dries Jans Jun 19 at 10:24
  • $\begingroup$ Damn how did I not thought about buffering. thanks for the answer $\endgroup$ – Dries Jans Jun 19 at 10:27
  • 1
    $\begingroup$ @DriesJans Whatever encryption algorithm you choose (the two of this answer are good choices), the weak point of your application will be the encryption key. You will have to protect it, to ensure it remains secret, otherwise your encryption is almost pointless. $\endgroup$ – A. Hersean Jun 19 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.