/***********************************************************
crypt.c -- 暗号
***********************************************************/
#N88BASIC
'Declare Sub srand CDECL Lib"msvcrt" (seed As DWord)
'Declare Function rand CDECL Lib"msvcrt" () As DWord
Dim c As Long, r As Long
Dim infile As HANDLE, outfile As HANDLE
Dim re As Long
infile = CreateFile("in.txt", GENERIC_READ, 0, ByVal 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
outfile = CreateFile("out.txt", GENERIC_WRITE, 0, ByVal 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
Dim tane As Long
Input "乱数の種", tane
srand(tane)
Do
c = ReadFile(infile, c, 1, VarPtr(re), ByVal 0)
If c = 0 Then Exit Do
Do
r = rand() / (32768 / 256)
Loop while r >= 256
WriteFile(outfile, c Xor r, 1, VarPtr(re), ByVal 0)
Loop
CloseHandle(infile):CloseHandle(outfile)