Exemplo n.º 1
0
Arquivo: librsa.c Projeto: lcurole/rsa
/** \brief Encrypt a plaintext string using RSA encryption and stores it
 *
 * \param pt[] char Plaintext
 * \param ct[] int Where ciphertext gets stored
 * \param e int Public Exponent
 * \param n int Modulus
 * \return void
 *
 */
void encrypt(char pt[], int ct[], int e, int n)
{
    int i;
    int pte[50000] = {};
    encodePlain(pt, pte);

    for (i = 0; pte[i] > 0; i++) //loop thru pte member
        ct[i] = encodeRSA(pte[i], e, n); //and RSA encrypt
    ct[i] = -1; //insert sentinel valuee
    return;
}
Exemplo n.º 2
0
/** \brief Encrypt a plaintext string using RSA encryption and stores it
 *
 * \param pt[] char Plaintext
 * \param ct[] int Where ciphertext gets stored
 * \param e int Public Exponent
 * \param n int Modulus
 * \return void
 *
 */
void RSA::RSAEncrypt( char pt[], int ct[], int e, int n,int size )
{
    int i;
    int *pte = new int[size+1];

    encodePlain(pt, pte,size);

    for (i = 0; i < size; i++) //loop thru pte member
        ct[i] = encode(pte[i], e, n); //and RSA encrypt

	delete pte;

    return;
}