RC-PoR-P-Source-cod/RC-PoR-P.cpp
bigint* encrypt(int val, byte* key, int key_size, byte* iv, int byte_){

  string cipher, temp;
  CBC_Mode< AES >::Encryption e;
  bigint* res;
  res = (bigint*)malloc(1 * sizeof(mpz_t));
  unsigned char prn_[byte_];
  e.SetKeyWithIV(key, key_size, iv);
  StringSource sss(to_string(val), true, new StreamTransformationFilter(e, new StringSink(cipher)));
  temp = cipher.substr (0, byte_);// truncate the ciphertext
  memset(prn_, 0x00, byte_ + 1);
  strcpy((char*)prn_, temp.c_str());
  mpz_init(res[0]);
  mpz_import(res[0], byte_, 1, 1, 0, 0, prn_);
  return res;
}
//=================================
// description: encrypts "val" given the key and initial vector.
encrypts "val" given the key and initial vector.
encrypts " val " given the key and initial vector .
bigint* encrypt(int val, byte* key, int key_size, byte* iv, int byte_){
  string cipher, temp;
  CBC_Mode< AES >::Encryption e;
  bigint* res;
  res = (bigint*)malloc(1 * sizeof(mpz_t));
  unsigned char prn_[byte_];
  e.SetKeyWithIV(key, key_size, iv);
  StringSource sss(to_string(val), true, new StreamTransformationFilter(e, new StringSink(cipher)));
  temp = cipher.substr (0, byte_);
  memset(prn_, 0x00, byte_ + 1);
  strcpy((char*)prn_, temp.c_str());
  mpz_init(res[0]);
  mpz_import(res[0], byte_, 1, 1, 0, 0, prn_);
  return res;
}
bigint * encrypt ( int val , byte * key , int key_size , byte * iv , int byte_ ) { string cipher , temp ; CBC_Mode < AES > :: Encryption e ; bigint * res ; res = ( bigint * ) malloc ( 1 * sizeof ( mpz_t ) ) ; unsigned char prn_ [ byte_ ] ; e . SetKeyWithIV ( key , key_size , iv ) ; StringSource sss ( to_string ( val ) , true , new StreamTransformationFilter ( e , new StringSink ( cipher ) ) ) ; temp = cipher . substr ( 0 , byte_ ) ; memset ( prn_ , 0x00 , byte_ + 1 ) ; strcpy ( ( char * ) prn_ , temp . c_str ( ) ) ; mpz_init ( res [ 0 ] ) ; mpz_import ( res [ 0 ] , byte_ , 1 , 1 , 0 , 0 , prn_ ) ; return res ; }
description: encrypts "val" given the key and initial vector.
description : encrypts " val " given the key and initial vector .
// truncate the ciphertext