AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   File reading as ASCII/Binary (not inhibited by line breaks) (https://forums.alliedmods.net/showthread.php?t=5715)

Anpheus 09-10-2004 18:15

File reading as ASCII/Binary (not inhibited by line breaks)
 
I've written a Small implementation of the simple SHA1 algorithm, I'm wondering how the best method would be of reading data from the file, ignoring line breaks?

Another question: Does standard md5, SHA1, etc, file hashing include the file header, and if so, how would I read that as an ASCII sequence in a clean manner?

Anpheus 09-11-2004 17:06

bump.


Somebody's got to have a good method.

malex 09-11-2004 23:00

1) You want to use the fread() native, from file.inc, to read without paying attention to the line breaks.

2) What header are you talking about? Normally, the digest is taken of the entire file contents.

\malex\

Anpheus 09-12-2004 00:00

Right, sorry, I meant handle.

I guess I misread it, handle makes way more sense than header. And that it returns a handle and what not... yeh.

Edit: Actually, I need to be able to -resume- from a specific spot as well.

SHA, Rijndael, etc, they dont require that the entire file is buffered immediately. Just in chunks. For SHA this is 512 bits, for Rijndael it is 128, 192, or 256.



So, how do I read directly from the file, from byte/bit x, to byte/bit x?

Anpheus 09-13-2004 16:27

Hello?

BAILOPAN 09-13-2004 17:20

I said it before, I'll say it again

small is not meant for this stuff. use a module

Twilight Suzuka 09-13-2004 18:16

Small can handle it!
*pats smoking small*
...yeah. Module.

Anpheus 09-13-2004 23:11

Pfft, it can do it. I wrote SHA-1 in JASS..

JASS HAS NO BITWISE OPERATORS!



I can do it if I can just get it to read from a file. 512 bits at a time.

BAILOPAN 09-14-2004 00:54

I don't care if you've written a Rijndael quine in brainfuck, the point is that doing this is just stupid.

The speed will be horrendously slow compared to that of a native C function. Did you not see the benchmarks comparing native small code to native C code? Have you the brain worms!?

Check out the amxxmodule sdk. it's quite nice. otherwise, take a look at file.inc there are C-style file functions there

Anpheus 09-14-2004 17:35

Haha... that's awesome. Brainfuck... the language.

Ok, ok, I guess I have to learn C++.


All times are GMT -4. The time now is 17:12.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.