mirror of
https://github.com/codestation/mhtools
synced 2024-11-10 05:44:17 +00:00
Added check to --encrypt to make sure that the files have the
same length as the indicated in the index table
This commit is contained in:
parent
1119fabe08
commit
4434e73314
1 changed files with 13 additions and 1 deletions
|
@ -36,7 +36,19 @@ public class Encrypter extends DecryptTable {
|
|||
try {
|
||||
RandomAccessFile filein = new RandomAccessFile(in, "r");
|
||||
RandomAccessFile fileout = new RandomAccessFile(out, "rw");
|
||||
initSeed(getOffset(extractNumber(in)));
|
||||
int file_number = extractNumber(in);
|
||||
long file_len = filein.length();
|
||||
long table_len = (getOffset(file_number + 1) << 11) - (getOffset(file_number) << 11);
|
||||
if(file_len < table_len) {
|
||||
System.out.println(in + " filesize is less than the stored table by " +
|
||||
(table_len - file_len) + " bytes, fill the file with 0x00 at the end");
|
||||
System.exit(1);
|
||||
}else if(file_len > table_len) {
|
||||
System.err.println(in + " filesize is greater than the stored table by " +
|
||||
(file_len - table_len) + " bytes, aborting");
|
||||
System.exit(1);
|
||||
}
|
||||
initSeed(getOffset(file_number));
|
||||
byte[] buffer = new byte[4];
|
||||
System.out.println("Encrypting " + in);
|
||||
while (filein.read(buffer) >= 0) {
|
||||
|
|
Loading…
Reference in a new issue