Questions tagged [encryption]

Encryption is the process of transforming information (called plaintext) into an unreadable form (called ciphertext) using an encryption algorithm using a secondary parameter (called an encryption key). Only those who possess the decryption key can easily reverse the process and recover the original plaintext. Conceptual questions about encryption may get better answers on crypto.stackexchange.com.

In cryptography, encryption is the process of transforming information (called plaintext) into an unreadable form (called ciphertext) using an encryption algorithm combined with a parameter called an encryption key. Reversing the process, that is transforming the ciphertext into plaintext, is called decryption. Only those who possess the decryption key can reverse the process and recover the original plaintext.

There are 2 types of encryption methods generally:

  • symmetric
  • asymmetric

In symmetric encryption the encryption and decryption keys are the one and the same; this single key is sometimes called the shared secret key. Rijndael(AES), TwoFish, and Cha-Cha are examples of symmetric encryption algorithms.

In asymmetric encryption, also known as public key encryption, the encryption and decryption keys are different. The encryption key is called the public key and the decryption key is called the private key. RSA, Diffie-Hellman (DH), El-Gamal (ElG), and elliptic curve variants of DH and ElG are examples of public key encryption algorithms.

The term "encryption" should be reserved for transformations intended to be reversed or "decrypted". In particular, cryptographic transformations intended to be one way, such as cryptographic hash algorithms (e.g. SHA1, SHA2, SHA3) and password hashing algorithms (e.g. bcrypt, scrypt) should not be referred to as "encryption".

Encryption has long been used by militaries and governments to facilitate secret communication. Encryption is now commonly used in protecting information within many kinds of civilian systems. It can be used to protect data "at rest", such as files on computers and storage devices (e.g. USB flash drives). In recent years there have been numerous reports of confidential data such as customers' personal records being exposed through loss or theft of laptops or backup drives. Encrypting such files at rest helps protect them should physical security measures fail. Digital rights management systems which prevent unauthorized use or reproduction of copyrighted material and protect software against reverse engineering (see also copy protection) are another somewhat different example of using encryption on data at rest.

Encryption is also used to protect data in transit, for example data being transferred via networks (e.g. the Internet, e-commerce), mobile telephones, wireless microphones, wireless intercom systems, Bluetooth devices and bank automatic teller machines. There have been numerous reports of data in transit being intercepted in recent years. Encrypting data in transit also helps to secure it as it is often difficult to physically secure all access to networks.

Encryption, by itself, can protect the confidentiality of messages, but other techniques are still needed to protect the integrity and authenticity of a message; for example, verification of a message authentication code (MAC) or a digital signature. Standards and cryptographic software and hardware to perform encryption are widely available, but successfully using encryption to ensure security may be a challenging problem. A single slip-up in system design or execution can allow successful attacks. Sometimes an adversary can obtain unencrypted information without directly undoing the encryption. See, e.g., traffic analysis, TEMPEST, or Trojan horse.

One of the earliest public key encryption applications was called Pretty Good Privacy (PGP). It was written in 1991 by Phil Zimmermann and was purchased by Network Associates (now PGP Corporation) in 1997.

Source: Wikipedia.

See also:


Note: conceptual questions about encryption might get more attention and better answers from the Crypto stack exchange.

36876 questions
171
votes
9 answers

SQLite with encryption/password protection

I'm just learning to use SQLite and I was curious if such is possible: Encryption of the database file? Password protect opening of the database? PS. I know that there is this "SQLite Encryption Extension (SEE).", but according to the…
ahmd0
  • 16,633
  • 33
  • 137
  • 233
167
votes
10 answers

Hash function that produces short hashes?

Is there a way of encryption that can take a string of any length and produce a sub-10-character hash? I want to produce reasonably unique ID's but based on message contents, rather than randomly. I can live with constraining the messages to…
user234932
162
votes
5 answers

encryption/decryption with multiple keys

Is it possible to encrypt data, such that it can be decrypted with several different keys? Example: I've encrypted data with key1, but I want to be able to decrypt with keys 2, 3, and 4. Is this possible?
Glen Solsberry
  • 11,960
  • 15
  • 69
  • 94
160
votes
9 answers

Difference between Hashing a Password and Encrypting it

The current top-voted to this question states: Another one that's not so much a security issue, although it is security-related, is complete and abject failure to grok the difference between hashing a password and encrypting it. Most commonly found…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
156
votes
16 answers

Converting a Java Keystore into PEM Format

I am trying to convert from a Java keystore file into a PEM file using keytool and openssl applicactions. But I could not find a good way to do the conversion. Any ideas? Instead of converting the keystore directly into PEM I tried to create a…
Chathuranga Chandrasekara
  • 20,548
  • 30
  • 97
  • 138
154
votes
2 answers

What are the differences between .pem, .cer and .der?

What are the differences between .pem, .cer and .der? As far as I know, .cer contains public key. Are there any open frameworks that I can use to encrypt my data using this public key?
LiangWang
  • 8,038
  • 8
  • 41
  • 54
144
votes
7 answers

Given final block not properly padded

I am trying to implement password based encryption algorithm, but I get this exception: javax.crypto.BadPaddingException: Given final block not properly padded What might be the problem? Here is my code: public class PasswordCrypter { private…
Altrim
  • 6,536
  • 4
  • 33
  • 36
142
votes
4 answers

How to encrypt bytes using the TPM (Trusted Platform Module)

How can I encrypt bytes using a machine's TPM module? CryptProtectData Windows provides a (relatively) simple API to encrypt a blob using the CryptProtectData API, which we can wrap an easy to use function: public Byte[] ProtectBytes(Byte[]…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
142
votes
10 answers

Encrypt password in configuration files

I have a program that reads server information from a configuration file and would like to encrypt the password in that configuration that can be read by my program and decrypted. Requirements: Encrypt plaintext password to be stored in the…
Petey B
  • 11,439
  • 25
  • 81
  • 101
141
votes
5 answers

What is the optimal length for user password salt?

Any salt at all will obviously help when salting and hashing a user's password. Are there any best practices for how long the salt should be? I'll be storing the salt in my user table, so I would like the best tradeoff between storage size and…
David
  • 7,487
  • 6
  • 32
  • 25
134
votes
7 answers

How does BitLocker affect performance?

I'm an ASP.NET / C# developer. I use VS2010 all the time. I am thinking of enabling BitLocker on my laptop to protect the contents, but I am concerned about performance degradation. Developers who use IDEs like Visual Studio are working on lots and…
Christopher
  • 10,409
  • 13
  • 73
  • 97
133
votes
6 answers

Converting Secret Key into a String and Vice Versa

I am generating a key and need to store it in DB, so I convert it into a String, but to get back the key from the String. What are the possible ways of accomplishing this? My code is, SecretKey key =…
Princeyesuraj
  • 5,228
  • 6
  • 22
  • 27
133
votes
9 answers

How to send password securely over HTTP?

If on a login screen user submits a form with their username and password, the password is sent in plain text (even with POST, correct me if I am wrong). What is the right way to protect the user and his password against the third party who might be…
Kornelije Petak
  • 9,412
  • 15
  • 68
  • 96
128
votes
8 answers

I need to securely store a username and password in Python, what are my options?

I'm writing a small Python script which will periodically pull information from a 3rd party service using a username and password combo. I don't need to create something that is 100% bulletproof (does 100% even exist?), but I would like to involve a…
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411
128
votes
3 answers

What is the meaning of ToString("X2")?

I'm studying MD5 encryption, and have found this code using Google: public string CalculateMD5Hash(string input) { // Primeiro passo, calcular o MD5 hash a partir da string MD5 md5 = System.Security.Cryptography.MD5.Create(); byte[]…
Lai32290
  • 8,062
  • 19
  • 65
  • 99