// Detect It Easy: detection rule file
// Author: LinXP
// doc-ref: https://peazip.github.io/pea_help.pdf

meta("archive", "PeaZip (.PEA)");

function detect() {
    if (Binary.getSize() >= 10) {
        if (Binary.compare("EA") && Binary.compare("0000'POD'00", 0x0A)) {
            sVersion = "v" + Binary.read_uint8(0x01) + "." + Binary.read_uint8(0x02)
            bDetected = true;

            if (bDetected && Binary.isVerbose()) {
                switch (Binary.read_uint8(0x3)) {
                    case 0: sOption("NOALGO"); break;
                    case 1: sOption("ADLER32"); break;
                    case 2: sOption("CRC32"); break;
                    case 3: sOption("CRC64"); break;
                    case 16: sOption("MD5"); break;
                    case 17: sOption("RIPEMD160"); break;
                    case 18: sOption("SHA1"); break;
                    case 19: sOption("SHA256"); break;
                    case 20: sOption("SHA512"); break;
                    case 21: sOption("WHIRLPOOL"); break;
                    case 22: sOption("SHA3_256"); break;
                    case 23: sOption("SHA3_512"); break;
                    case 24: sOption("BLAKE2S"); break;
                    case 25: sOption("BLAKE2B"); break;
                    default:
                        bDetected = false;
                }
            }
        }
    }

    return result();
}