- a2a.out :
ファイル名 uecoo の内容と同じものを ファイル名 goo にコピーする例。
> gcc -o a2a.out a2a.c //オプション -o で実行ファイル名 a2a.out を指定して,コンパイルする
> cat uecoo // catコマンドでファイの中身を確認
The University of Electro Communications
> ./a2a.out uecoo goo //入力ファイルfoo、 出力ファイルgoo
> cat goo
The University of Electro Communications
> diff uecoo goo //diff コマンドでファイル内容の比較(差分をとる)
>
- a2AA.c :ファイル名 uecoo の内容に記述されている中の英字における大文字を小文字に変換し、一方、小文字を大文字に変換し、
ファイル名 goo に出力する例。
> gcc -o a2AA.out a2AA.c //オプション -o で実行ファイル名 a2AA.out を指定して,コンパイルする
> cat uecoo //catコマンドでファイの中身を確認
The University of Electro Communications
> ./a2AA.out uecoo goo //入力ファイルfoo、 出力ファイルgoo
> cat goo
tHE uNIVERSITY OF eLECTRO cOMMUNICATIONS
>
- shift.c : シフト暗号の実行例 (共通鍵 k=5 の場合の例)
> gcc -o shift.out shift.c //オプション -o で実行ファイル名 shift.out を指定して,コンパイルする
> cat foo //catコマンドでファイの中身を確認
WEWILLMEETATCHOFUSTATION
> ./shift.out -e 5 foo goo // 暗号化 オプション -e, 鍵 5, 入力ファイル名(平文):foo, 出力ファイル名(暗号文):goo
> cat goo
BJBNQQRJJYFYHMTKZXYFYNTS
> ./shift.out -d 5 goo hoo // 復号化 オプション -d, 鍵 5, 入力ファイル名(暗号文):goo, 出力ファイル名(推定平文):hoo
> cat hoo
WEWILLMEETATCHOFUSTATION
> diff foo hoo
>
-
rsa.out : RSA暗号の実行例 : (公開鍵(9893,32399), 秘密鍵(7475,32399)とした場合の例)
> cat foo
WEWILLMEETATCHOFUSTATION
> ./rsa.out -e 9893 32399 foo goo // 暗号化 オプション -e, 公開鍵(9893,32399), 入力ファイル名(平文):foo, 出力ファイル
名(暗号文):goo
>
> cat goo // 文字化けして、正しく表示できない
�(f�(%rwwEff�v&3�vrx}�cA�Y�,�v&3�v%r�c�U>
>
>
> ./rsa.out -d 7457 32399 goo hoo // 復号化 オプション -d, 秘密鍵(7475,32399), 入力ファイル名(暗号文):goo, 出力ファイル名(推定平文):hoo
> cat hoo
WEWILLMEETATCHOFUSTATION
> diff foo hoo
> ls -la | grep oo
-rw-r--r-- 1 xx staffs 101 Aug 31 14:40 aoo
-rw-r--r-- 1 xx staffs 25 Aug 31 14:40 foo
-rw-r--r-- 1 xx staffs 50 Oct 2 15:28 goo
-rw-r--r-- 1 xx staffs 25 Oct 2 15:28 hoo
-rw-r--r-- 1 xx staffs 41 Aug 31 14:40 uecoo
-rw-r--r-- 1 xx staffs 52 Aug 31 14:40 weoo
>
- prime.out : 100までの素数と、1万までの素数を求める実行例
> ./prime.out 100 // 100までの素数を求める
...start Finding Primes.
...Finding primes in the range [2,3, ... ,100]
------------
2
3
5
(中省略)
97
------------
The number of primes is 25
...end Finding Primes.
>
>
> ./prime.out 10000 // 10000までの素数を求める
...start Finding Primes.
...Finding prime in range [2,3, ... ,10000]
------------
2
3
5
(中省略)
9973
------------
The number of primes is 1229
...end Finding Primes.
>
-
gcd.out :拡張ユークリッド法と最大公約数を求める実行例(入力が 144, 29 の場合)
> ./gcd.out 144 29
...start finding gcd(144,29) and (f,g) such that f*(144)+g*(29)=gcd(144,29)
Input : ( a, b ) = ( 144, 29 )
Output : gcd( a, b ) = gcd( 144, 29 ) = 1
: ( f, g ) = ( -1, 5 )
such that ( f * a ) + ( g * b ) = gcd( a, b )
that is ( -1 * 144 ) + ( 5 * 29 ) = 1
...end.
>
-
lcm.out : 最小公倍数を求める実行例(入力が 16, 18 の場合)
> ./lcm.out 16 18
...start finding lcm(16,18)
Input : ( a, b ) = ( 16, 18 )
Output : lcm(a,b) = lcm(16,18) = (16*18) / gcd(16,18) = 144
where 16*18=288 and gcd(16,18) = 2
...end.
>
-
findinge.out : 144に対し、gcd(e,144)=1 かつ 1< e < 144 を満たす e をすべて求める実行例
> ./findinge.out 144
...start Computing keys by Euclid algorithm(Command Line version).
...Finding inegers e such that gcd(e,144)=1 and 1 < e < 144.
5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47, 49, 53, 55, 59, 61, 65, 67, 71, 73, 77, 79, 83, 85, 89, 91, 95, 97, 101, 103, 107, 109, 113, 115, 119, 121, 125, 127, 131, 133, 137, 139, 143,
...end Computing keys by Euclid algorithm(Command Line version).
>