You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cryptography.bigb
+39-2Lines changed: 39 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -37,9 +37,37 @@ The downside is that that you have to type your password every time you want to
37
37
38
38
The other main type of encryption is <public-key cryptography>.
39
39
40
-
The advantage of <public-key cryptography> is that it allows you to send secret messages to other people even if the attacker is able to capture the encrypted messages. This is for example what you want to do when sending a personal message to a special friend.
40
+
The advantage of <public-key cryptography> is that it allows you to send secret messages to other people even an the attacker is able to capture the encrypted messages. This is for example what you want to do when sending a personal message to a friend over the <Internet>. Such <encryption> is especially crucial when using <wireless communication> such as <Wi-Fi>, where anyone nearby can capture the signals you send and receive, and would be able to read all your data if it weren't encrypted.
41
41
42
-
This is not possible with <symmetric encryption> because for your friend to decrypt the message in that system, you'd need to send them the password, which the attacker would also be able to eavesdrop and then decrypt the message.
42
+
Easily sending encrypted messages over the <Internet> is not possible with <symmetric encryption> because for your friend to decrypt the message in that system, you'd need to send them the password, which the attacker would also be able to eavesdrop and then decrypt the message that follows using it. The problem of sharing a password with another person online is called <key exchange>.
43
+
44
+
<Advanced Encryption Standard> (AES) is one of the most popular families of <symmetric encryption> algorithms.
45
+
46
+
<OpenSSL> is a popular <open source> implementation of <symmetric and public-key cryptography>. A simple example of using <OpenSSL> for <symmetric encryption> from the <command-line> is:
47
+
``
48
+
echo 'Hello World!' > message.txt
49
+
openssl aes-256-cbc -a -salt -pbkdf2 -in message.txt -out message.txt.enc
50
+
``
51
+
This asks for a password, which we set as `asdfqwer`, and then produces a file `message.txt.enc` containing garbled text such that:
00000020 4e 37 6d 52 2f 73 6d 4d 62 64 30 3d 0a |N7mR/smMbd0=.|
60
+
0000002d
61
+
``
62
+
Then to decrypt:
63
+
``
64
+
openssl aes-256-cbc -d -a -pbkdf2 -in message.txt.enc -out message.new.txt
65
+
``
66
+
once again asks for your password and given the correct password produces a file `message.new.txt` containing the original message:
67
+
``
68
+
Hello World!
69
+
``
70
+
This was tested on <Ubuntu 24.04>, OpenSSL 3.0.13. See also: https://stackoverflow.com/questions/16056135/how-to-use-openssl-to-encrypt-decrypt-files[How to use OpenSSL to encrypt/decrypt files? on Stack Overflow].
0 commit comments