Note that there are some explanatory texts on larger screens.

plurals
  1. POUnderstanding RSA cell padding from textbook explaination
    primarykey
    data
    text
    <p>I've been doing an RSA encryption/decryption assignment for a school assignment, and I've actually gotten the whole thing working. The one thing I want to make sure I understand is the padding. The book states that after we turn the string of characters into a string of digits (A = 00, and Z = 25) we then need to determine the size of the blocks and add dummy characters to the end.</p> <p>The book states:</p> <blockquote> <p>Next, we divide this string into equally sized blocks of 2N digits, where 2N is the largest even number such that the number 2525 ... 25 with 2N digits does not exceed n.</p> </blockquote> <p>It doesn't tell me where it gets 25 from, so I deduced that it was the index of the last character (Z in this case) of the our actual key of characters.</p> <p>So here is my Python3 implementation (fair warning it is somewhat cringe-worthy):</p> <pre><code>alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def __determineSize__(message, n): if (n &lt; len(alphabet) - 1): raise Exception("n is not sufficiently large") buffer = "" for i in range(0, n, 2): buffer += str(len(alphabet) - 1) #+= "25" in this case if (int(buffer) &gt; n): groupSize = len(buffer) - 2 return groupSize </code></pre> <p>It starts with 25 ( len(alphabet) = 26, 26 - 1 = 25), if it is not larger than n we increase it to 2525. If it larger at this point we stop because we know we've gone to far and we return the length 2, because the length 4 is too large.</p> <p>This is how I understood it, and it works but it doesn't seem right. Did I interpret this correctly or am I completely off base? If I am can someone set me straight? (I'm not asking for code, because it's for an assignment I don't want to plagerise anyone so if anyone could just tell me what I'm supposed to do in simple English or show me in pseudo code that would be great.)</p> <p>Like always, thanks to everyone in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload