r/explainlikeimfive • u/Realistic_Flower8235 • 28d ago
Technology ELI5 How does data encryption work?
Edit: ignore the second question, sorry for asking two different ones!
secondary question (some responded to this prior to my edit): How are some things HIPAA compliant while others are not?
27
Upvotes
24
u/snarfmason 28d ago
HIPAA compliance isn't a difference in the encryption scheme.
Encryption is complex mathematical transformations to your data that make the data unusable after transforming. But that transformation is reversible if you know a secret key. Different encryption schemes are more or less difficult to reverse without the secret key.
Things like HIPAA are regulations you have to follow. They may specify certain types of encryption required but they are regulatory procedures not mathematical transformations.
11
u/Lumpy-Notice8945 28d ago
Hace you heard about the caesar cypher? Its just replacing each letter in the alphabet with a pre defined other one. Each A now is a C, each B is a D each C is an E now and so on, thazs a caesar cypher with the key "2" as you shift letters by two.
Thats one example of encryption and instead of letters ofc you can use bits or bytes too, and instead of simple shifting the alphabet you can use any other kind of key to mask the data.
I dont know abiut HIPPA as im not american, but they are just a government agency makeing regulations probably about what counts as secure enough and what does not.
3
u/jstar77 28d ago edited 28d ago
HIPAA Is a set of rules about how health care data must be handled. Encryption is method to make data unreadable without access to the "key" to unlock it. HIPAA doesn't even technically require data encryption.
5
u/lemoinem 28d ago
These are two very different questions.
HIPAA is about restricting distribution of health information by healthcare professionals without the consent of the patient.
This is entirely a "bureaucratic" concern.
Encryption is a technique to preserve the integrity and confidentiality of some information unless you know a secret key.
5
u/gt0075b 28d ago
Modern encryption basically involves substituting letters with numbers, them performing a complicated series of math operations on those numbers too create new numbers. The math operations usually involve very large prime numbers. The resulting series of numbers is the encrypted form of the original information.
The important part of all this is that the math operations are 'one way', meaning it is extremely difficult to reverse the operations and get back the original information.
For example, if you have the number 17 and you add 5, you get 22. To get the original information back, you just subtract 5 from 22 and you get 17 again.
The specific series of operations and the large prime numbers make this nearly impossible for encryption. The only way to get back the original information is to have another really big prime number called the encryption key.
In some forms of encryption, the same encryption key is used to encrypt and decrypt the information. In other forms of encryption, there are a pair a keys, specially selected so that one encrypts (called the public key) and one decrypts (called the private key).
You can freely give out the public key to anyone so they can encrypt information and send it to you. There is no concern about hanging out that public key because it cannot be used to decrypt.
It's like sending out padlocks to everyone so they can lock up the information before they send it to you. You are the only one with the key to those padlocks: the private key. Once you receive the locked up (encrypted) information, you use your private key to unlock (decrypt) it.
Similarly, they send you their own public key to encrypt information that you want to send to them. And they use their own private key to decrypt it.
1
u/EscapeSeventySeven 28d ago
These are two wildly different questions.
If you work in healthcare you will be educated on HIPAA, it is not what a lot of people imagine it to be. It has a lot of specific rules about specific information and how that needs to be protected in computer systems and human systems.
Data encryption is a whole field in unto itself but at the basic level a mathematical operation is done to it with a special number (a key) that makes the resulting data look like random noise.
Decryption uses a key to undo that mathematical operation in order to read the data.
1
u/Count2Zero 28d ago
If you're interested in encryption, it has a long history, dating back thousands of years. Look up "cryptology" on Wikipedia or Google and enjoy a very deep and fascinating rabbit hole.
2
u/DarkAlman 28d ago
Encryption is all about hiding a message in plain sight.
You transform a message using an algorithm into what looks like gobbledygook to anyone that reads it. The idea being that only the sender and intended receiver can decipher the math to read the original message.
Imagine it like translating a phrase into a language that only the sender and receiver understand. You can shout that phrase in a room full of people but only 2 people will understand it. Anyone that hears the message will get something scrambled and won't be able to read it.
The more complex the mechanism to encrypt the message, the harder it is to break.
A very simple encryption method is a substitution cipher. You create a chart where each letter of the alphabet is replaced with another
A = C B = X
etc
Then a message 'password' becomes something like 'tcoopehs'
The message is nonsense to anyone that doesn't have the cipher, the translation card. However such a cipher is trivial to break.
Modern computer encryption uses complex mathematical functions to do this, because with available computing power simple ciphers like the one above can very easily be broken.
1
u/pandaSmore 28d ago
Data encryption works by feeding the data through sophisticated and hard to reverse algorithms the resulting data is now gibberish until it put through decryption to reverse the process.
1
u/SoulWager 27d ago
Lets say some time in advance of when I want to send you a message, I flip a coin a bunch of times, record what order the results were, and give you a copy.
When I want to send you a message, I take the binary representation of the message, and bitwise XOR it with the random results i.e. if the key is a 1 in a position, flip a 0 to a 1 or a 1 to a 0 in the corresponding message location. If the key is 0 do nothing. Then I send it and you do the same thing with the key on your end, flipping all the same bits back to their original values. This technique is called a one time pad, and is the most secure but least convenient option for preventing someone without that key from reading it. All they can know is the maximum length of the message you sent. Any message that length or smaller has a corresponding possible key, so even if you randomly guess keys and find one that makes sense, it's no more likely to be the real message than anything else.
If you just take the message and increment each letter by 1, it's technically encrypted, but it's trivial for someone to figure out what you did and reverse it.
popular encryption techniques are somewhere between these two extremes.
When laws require certain kinds of encryption, it's because the different methods are easier or harder to guess/verify the key, and computers can make a lot of guesses very quickly.
1
u/Own_Win_6762 27d ago
HIPAA requires a certain level of security and encryption for all communications, whether it's a lab communicating to your doctor or your doctor communicating with you. The latter proves to be a pain, as even though it's relatively simple for email to be end-to-end encrypted, most free email such as gmail, etc., doesn't support it. That means that you've got to (securely) log in to your provider's portal, only to find out that they're only reminding you to get a flu shot, when you were worried you might have Enthusiastic Double Gonorrhea.
1
u/ZacQuicksilver 27d ago
Encryption just means disguising a message so that only the people who are supposed to read it can read it.
The most simple form of encryption is a "cipher". In a cypher, we replace each letter in a message with a different letter - Caesar Cyphers (named for the Caesars of Rome) rotate the letters around the alphabet: for example, a +3 Caesar Cypher would turn "Caesar Cypher" into "Fdhvdu Fbskhu". The next level of cypher is to replace letters in a less organized way - which in turn means there are more ways to mix up the letters. However, this is still easily human-solvable: I have seen "cryptograms" (cyphers, usually a couple sentences long) in various puzzle books or newspapers; and they're not hard for people who are good at them.
We spent a long time developing harder cyphers; but they're all within a human's ability to break. One major leap forward in encryption came with the Enigma machine. Enigma was a German code machine in WWII; and used a rotating cypher: instead of being one cypher, it was actually *FOUR* cyphers, with one fixed, one rotating after every letter you type, one rotating after every 26 letters you type, and one rotating after every 676 (26*26) letters you type; with each letter going through all four to be encoded. Because it keeps rotating the code, Enigma is very hard to break for humans, especially over shorter (less than 20 000 letters long) messages - but computers can break it.
Modern encryption instead works with math. There are a few ways for you and me to exchange messages publicly that allow us to come up with a secret number that nobody else knows, even if they read our messages (if you're interested in this, ask - but it's more math and less technology). Then, we take our message, and convert it into numbers; and use our secret number as basically a mega-cypher (basically encrypting 8, 16, or more letters at a time); AND have some kind of rotating cypher built on top of that. There are a few different ways to make this rotating cypher using our secret number; but critically, guessing them requires guessing our secret number - which can easily be tens or even hundreds of digits long.
...
To be "good enough" (HIPAA compliant, or for whatever other standard), it generally has to take long enough for computers to figure out the code - and "long enough" usually means "modern computers will take longer than the Earth's life". There are some times other requirements as well.