Article View: fj.lang.c
Article #532Re: Q:暗号化
From: Ransui Iso
Date: Mon, 30 Mar 1998 00:00
Date: Mon, 30 Mar 1998 00:00
52 lines
2223 bytes
2223 bytes
磯@青山学院大学です。
Bat wrote:
> こんにちは。
>
> Cで文字列を暗号化するにはどのような方法があるのでしょうか。代表的なものを
> いくつか教えていただけないでしょうか?
#include <stdio.h>
void main(int argc, char **argv)
{
int c;
while ((c = fgetc(stdin)) != EOF)
fputc((c + 13) % 256, stdout);
}
なんてのはどうでしょう?
ROT13のつもりです。めちゃくちゃ古い暗号化方法で、こんなのは
暗号とは言えないレベルです。間違っても自分のプログラムに使ったり
しないように>このプログラム
MS-DOSとかに固有のテキストモードとかバイナリモードとか考えてないです。
ちなみにこれをLinux+gccでコンパイルして実行すると。
mirage(90)%gcc -o angou angou.c
mirage(91)%od -ha hello.text
0000000 6548 6c6c 206f 6f57 6c72 2164 000a
H e l l o sp W o r l d ! nl nul
0000015
mirage(92)%cat hello.text | angou > hello.crypted
mirage(93)%od -ha hello.crypted
0000000 7255 7979 2d7c 7c64 797f 2e71 0017
U r y y | - d | del y q . etb nul
0000015
mirage(94)%
こんなかんじでしょうか。復号は自分で考えてくださいね>batさん
基本は、ある数を別の数に置きかえる関数をいろいろいじるという
感じになります。詳しくは、暗号の専門書を呼んでください。
--
----------------------------------------------------------------
Ransui Iso : ransui@ina-lab.ise.aoyama.ac.jp
http://noa.ise.aoyama.ac.jp/members/ransui/
^ ^
(@v@) Inazumi-Lab.
()###() Industrial and Systems Engineering Dept. AGU.
====m=m=========================================================
Technical Details
Message-ID:
<351E8F60.D7A59904@ina-lab.ise.aoyama.ac.jp>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<6fkn4d$h5r$1@news1.dti.ne.jp>Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS X-Google-Thread: 106434,d7a1f9e0b2aa78a4 X-Google-Attributes: gid106434,public From: Ransui Iso <ransui@ina-lab.ise.aoyama.ac.jp> Subject: Re: Q:暗号化 Date: 1998/03/30 Message-ID: <351E8F60.D7A59904@ina-lab.ise.aoyama.ac.jp> X-Deja-AN: 338880067 Content-Transfer-Encoding: 7bit References: <6fkn4d$h5r$1@news1.dti.ne.jp> Content-Type: text/plain; charset=iso-2022-jp Organization: Inazumi-Lab, I.S.E. Aoyama Gakuin Univ Mime-Version: 1.0 Newsgroups: fj.lang.c