Hello everyone
I have a question
http://stackoverflow.com/questions/157273836/ (http://stackoverflow.com/questions/57273836)
Hello. What you want to do looks trivial, but why do you want to treat quotes differently?
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
Init
mov ecx, CL$()
.if byte ptr [ecx]=="?"
MsgBox 0, "You forgot the commandline", "Hi", MB_OK
.else
Let esi=FileRead$(ecx)
push esi
.While 1
lodsb
.Break .if !al
xor al, 184
mov [esi-1], al
.Endw
pop esi
FileWrite "Xor184.txt", esi
Print "bye"
.endif
Exit
end start
I want to make symmetric encryption.
Key value: 180
a.txt = Hello
1)Read a.txt
2)H ASCII => 72
3)72 XOR 184 => ASCII
4)Write cryptic.txt
5)e ASCII => 101
6)101 XOR 184 => ASCII
7)Write cryptic.txt
Quote from: DangerZone on May 07, 2015, 06:58:44 PM
I want to make symmetric encryption.
Yes I know, that's what the proggie attached above does. But why special treatment for "quotes"?
Quote from: jj2007 on May 07, 2015, 06:49:13 PM
Hello. What you want to do looks trivial, but why do you want to treat quotes differently?
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
Init
mov ecx, CL$()
.if byte ptr [ecx]=="?"
Your program crashes.
Quote from: DangerZone on May 07, 2015, 07:39:47 PM
Your program crashes.
How (exception, error message, ...)?
Did you provide a valid commandline?
ok
OK, I see. Use Let instead of mov:
Init
Let ecx=CL$()
And remember the proggie needs to know which input file. Drag your input_whatever.txt over the xor.exe, and even the old version will work.
it was
thanks
get the file size (GetFileAttributesEx)
allocate a buffer (GetProcessHeap, HeapAlloc)
read the input file into the buffer (CreateFile, ReadFile, CloseHandle)
XOR the buffer - you can speed it up by XOR'ing 4 bytes at a time, except perhaps the last few bytes
write the buffer to the output file (CreateFile, WriteFile, CloseHandle)
free the buffer (HeapFree)
exit (ExitProcess)