Skip to content Skip to sidebar Skip to footer

How To Encrypt Text Using RSA Algo

I need to encrypt texts written in a file and decrypt it, without using the PyCrypto library. The file will contain string type data. Now I want to convert the strings to int numbe

Solution 1:

I too had this project, and I did this:

First what you will need is to read the datas from the text file and save it to a list. You can use .split() which will do this : If the file contains only one line like this

hello ! it will make it as

list_of_the_file['h', 'e', 'l', 'l', 'o', ' ', '!']

Now as you have a list of all the letters that the file contains serially, you can use the ord() which will generate a unique value for each type of character for example a or more precisely ord(a) will give you the value 97 and it will return 97 only for the a present in the list not for any other character. Then you can apply the keys on that integer value and can store it in a list or a file. Hope this will help.


Post a Comment for "How To Encrypt Text Using RSA Algo"