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
71
votes
7 answers

Using SHA1 and RSA with java.security.Signature vs. MessageDigest and Cipher

I'm trying to understand what the Java java.security.Signature class does. If I compute an SHA1 message digest, and then encrypt that digest using RSA, I get a different result to asking the Signature class to sign the same thing: // Generate new…
Kothar
  • 6,579
  • 3
  • 33
  • 42
71
votes
11 answers

How to Secure Android Shared Preferences?

The common location where SharedPreferences are stored in Android apps is: /data/data//shared_prefs/ User with root privileges can navigate to this location and can change its values.Need of protecting it is of much…
Harsh Dattani
  • 2,109
  • 1
  • 17
  • 27
71
votes
1 answer

Microsoft Crypto API Disable Use of RSAES-OAEP Key Transport Algorithm

I'm using CryptEncryptMessage to generate a PKCS#7 enveloped message. I'm using szOID_NIST_AES256_CBC as the encryption algorithm. The generated message appears to be valid but is the RSAES-OAEP for the Key Transport Algorithm which has limited…
user1775783
  • 818
  • 5
  • 4
71
votes
3 answers

How to Generate Unique Public and Private Key via RSA

I am building a custom shopping cart where CC numbers and Exp date will be stored in a database until processing (then deleted). I need to encrypt this data (obviously). I want to use the RSACryptoServiceProvider class. Here is my code to create my…
David Murdoch
  • 87,823
  • 39
  • 148
  • 191
70
votes
7 answers

Storing encryption keys -- best practices?

I have a web application that uses a symmetric encryption algorithm. How would you store the secret key and initialization vector? Storing as a literal in the code seems like a bad idea. How about app settings? What is the best practice here?
BC.
  • 24,298
  • 12
  • 47
  • 62
70
votes
10 answers

Given a private key, is it possible to derive its public key?

From whatever little I understand by reading various material, public-private key pair are the basis of asymmetric encryption and also something about choosing 2 prime numbers (which is roughly your private key) and multiplying them (which is…
Hemant
  • 19,486
  • 24
  • 91
  • 127
70
votes
1 answer

Example of AES using Crypto++

I have been searching the Internet for good c++ AES code sample/tutorial that teaches the basics of the encryption technology and the use of the Library but so far I have had no luck getting decent material. good: Easy to understand (Just the basics…
yohannist
  • 4,166
  • 3
  • 35
  • 58
70
votes
1 answer

Does has_secure_password use any form of salting?

I want to use has_secure_password to store encrypted passwords in the database. I can't find on the the internet if has_secure_password uses any form of salting. If it uses salting, how does it works? Can anyone clarify this for me? Thijs
Thijs
  • 3,015
  • 4
  • 29
  • 54
68
votes
7 answers

CryptographicException "Key not valid for use in specified state." while trying to export RSAParameters of a X509 private key

I am staring at this for quite a while and thanks to the MSDN documentation I cannot really figure out what's going. Basically I am loading a PFX file from the disc into a X509Certificate2 and trying to encrypt a string using the public key and…
kalrashi
  • 1,423
  • 3
  • 14
  • 15
68
votes
7 answers

How to export non-exportable private key from store

I need to export private key from Windows store. What should I do if the key is marked as non-exportable? I know that it is possible, program jailbreak can export this key. To export key I use Org.BouncyCastle.Security.DotNetUtilities.GetKeyPair()…
Gorf
  • 815
  • 1
  • 8
  • 12
68
votes
4 answers

RSA Encryption, getting bad length

When calling the following function : byte[] bytes = rsa.Encrypt(System.Text.UTF8Encoding.UTF8.GetBytes(stringToEncrypt), true); I am now getting the error: bad length. With a smaller string it works, any ideas what the problem could be the string…
JL.
  • 78,954
  • 126
  • 311
  • 459
67
votes
10 answers

PHP AES encrypt / decrypt

I found an example for en/decoding strings in PHP. At first it looks very good but it wont work :-( Does anyone know what the problem is? $Pass = "Passwort"; $Clear = "Klartext"; $crypted = fnEncrypt($Clear, $Pass); echo "Encrypted:…
Andreas Prang
  • 2,187
  • 4
  • 22
  • 33
66
votes
6 answers

When compressing and encrypting, should I compress first, or encrypt first?

If I were to AES-encrypt a file, and then ZLIB-compress it, would the compression be less efficient than if I first compressed and then encrypted? In other words, should I compress first or encrypt first, or does it matter?
Sei Satzparad
  • 1,137
  • 1
  • 9
  • 12
66
votes
2 answers

How do I use MS-XCEP and MS-WSTEP in .NET or JavaScript to get a certificate from AD CS?

Active Directory Certificate Services offers a web service that implements MS-XCEP and MS-WSTEP for non-domain connected computers to submit a certificate request. This certificate can be used for digital signatures, encryption, and more. Is there a…
makerofthings7
  • 60,103
  • 53
  • 215
  • 448
66
votes
5 answers

Simplest way to obfuscate and deobfuscate a string in JavaScript

I'm looking for a way to obfuscate and deobfuscate a string in JavaScript; by which I mean encryption and decryption when security is not an issue. Ideally something native to JS (like base64_encode() and base64_decode() in PHP) to "turn a string…
Rich Jenks
  • 1,723
  • 5
  • 19
  • 32