I was trying to implement the RSA algorithm myself. I have written the key generation part. My question is if I have the word "apple" which I want to encrypt, do I have to convert each alphabet to ASCII and then apply RSA to each letter or are there some other way?
It would make sense to encrypt as many bytes as possible at the same time. For example, a word like
apple can be written as this sequence of byte values in hexadecimal
65. You can treat this as a 40-bit number
0x6170706c65, which is equal to 418498243685. When this number is retrieved after decrypting the ciphertext, just convert it back into hexadecimal to get the original byte values.
Obviously you would need an RSA modulus of at least 40 bits to encrypt a word of this length. In practice, it would have to be a lot longer than that. An important part of RSA encryption is the use of randomized padding. Without it, the word
apple would always be encrypted to the same value, so an attacker could easily encrypt every word in the dictionary and compare the results with your ciphertext to find out what word you had encrypted.
Standard padding schemes like OAEP recommend the use of at least 64 random bits to ensure that the likelihood of the same word being encrypted the same way is negligibly small. You also need to ensure that your modulus can't easily be factored, which means it should be a number of at least 1024 bits.