0
$\begingroup$

I want to know how secure/insecure my implementation of the Caesar cipher is...

Ciphertext to decrypt :

39 83 82 75 86 69 88 89 80 69 88 77 83 82 87 4 83 82 4 72 73 71 86 93 84 88 77 82 75 4 88 76 77 87 4 81 73 87 87 69 75 73 4 5 4 18 18 18 4 45 4 72 77 72 4 82 83 88 4 88 76 77 82 79 4 77 88 4 91 83 89 80 72 4 70 73 4 90 73 86 93 4 87 73 71 89 86 73 4 69 82 93 91 69 93 87 4 31 13 -18 0 -111

Hints/Clues :

C Source [ Of program used for encryption/decryption - For those who know basic C]

Algorithm/Steps:

  • Encryption :
  1. Numeric Pin is taken. Pin should have 1 to 6 digits .
  2. Key is made from Pin. Key = (sum of digits in PIN - (sum/6))
  3. A Message is taken from the user, stored into a char array msg[]
  4. Each character x in msg[] is changed as : int d = (x - key) . Here, the ASCII value of char x is operated on.
  5. Each int is stored in an int array en[]. Then, all these ints are printed , with a space separating these , and the last number is always -111
  • Decryption:
  1. Pin is taken and key is generated from it.

  2. Ciphertext is taken from user.Whitespace separates the numbers as different elements of array where entered numbers are stored. -111 Terminates input.

  3. Every entered int d is stored as char ch such that : ch = (d + key). Char ch is then stored to char array msg[].

  4. Char array msg[] is printed.

  • Example :

message = "hello"

PIN = 123456

Key = (1+2+3+4+5+6) - [(1+2+3+4+5+6)/6] = 21 - (21/6) = 21 - 3.5 = ~ 18 (stored as 18, since key must be an int. )

ciphertext = 86 83 90 90 93 -8 33 -111

$\endgroup$
0
$\begingroup$

Yes, this is trivially crackable. It says

Congratulations on decrypting this message ! ... I did not think it would be very secure anyways ;)

It can easily be cracked by

just taking the lowest number, and using a shift of whatever would make that a space (32). Here, the lowest number is 4, so the key is 28.

Or, if you're too lazy to do the math there, you can just try all possible shifts. There aren't many options that will keep everything in the printable ASCII range.

This is a substitution cipher, so it is also crackable with fairly well-known cryptanalysis techniques. Frequency analysis easily breaks any substitution cipher with more than a few words of text; sites like Quipqiup do this automatically.

The "PIN" here doesn't have anything to do with the actual algorithm. It has effectively no security: its only purpose is to generate the key, and many different PINs will map to the same key.

So, this is less secure than the Caesar cipher, because you can figure out the key directly from the data without having tried a decryption!

| improve this answer | |
$\endgroup$
  • $\begingroup$ What if the user uses _ instead of space ? $\endgroup$ – A P Jo Aug 6 at 7:14
  • $\begingroup$ @JakeFry Then you just start at the key that that method gives you, and keep increasing by 1 until you get it. The range you need to try will still be smaller than 25 (which is what a Caesar cipher would get you). $\endgroup$ – Deusovi Aug 6 at 7:17
  • $\begingroup$ No, i dint get you... There are 0 spaces , only _ ... $\endgroup$ – A P Jo Aug 6 at 7:19
  • $\begingroup$ for example, decrypt this 31 32 33 34 77 98 86 87 97 77 87 97 77 92 99 98 97 -8 85 -111 $\endgroup$ – A P Jo Aug 6 at 7:21
  • $\begingroup$ @JakeFry It's 1234_this_is_nuts. I only had to try a few possible keys. It's very easy to do, even by hand. Since the "key" is just a single small number, all you have to do is try a few numbers until you get to the right one -- it takes seconds to figure out if you set it up in a spreadsheet. Start with the smallest number that gets them all into the range of printable ASCII, and just keep incrementing until you find the one that gives a message. $\endgroup$ – Deusovi Aug 6 at 7:28

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.