File: RSA_encipher.C

package info (click to toggle)
givaro 3.2.10-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,388 kB
  • ctags: 2,088
  • sloc: cpp: 11,000; sh: 9,193; makefile: 309; ansic: 93; sed: 4
file content (40 lines) | stat: -rw-r--r-- 707 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <fstream>
#include "givaro/givintrsa.h"
#include "givaro/givrandom.h"
#include "givaro/givtimer.h"

// RSA, in CBC mode, enciphering of files


int main(int argc, char** argv)
{
    Timer tim;
    tim.clear();
    
    IntRSADom<GivRandom>::Rep m,k;
    if (argc > 3)
        m = Integer( argv[3] );
    else 
        std::cin >> m;
    if (argc > 4)
        k = Integer( argv[4] );
    else 
        std::cin >> k;
    
    IntRSADom<GivRandom> IR(m,k);

    tim.start();
    std::ifstream TXT(argv[1]);
    std::ofstream OUT(argv[2]);
    IR.encipher( OUT, TXT );
    OUT.close();
    TXT.close();
    tim.stop();

    std::cerr << tim << std::endl;
    
   
    return 0;
}