2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.commons.compress.archivers.sevenz;
20
import org.tukaani.xz.LZMA2Options;
23
* The (partially) supported compression/encryption methods used in 7z archives.
25
public enum SevenZMethod {
26
/** no compression at all */
27
COPY(new byte[] { (byte)0x00 }),
28
/** LZMA - only supported when reading */
29
LZMA(new byte[] { (byte)0x03, (byte)0x01, (byte)0x01 }),
31
LZMA2(new byte[] { (byte)0x21 }) {
33
byte[] getProperties() {
34
int dictSize = LZMA2Options.DICT_SIZE_DEFAULT;
35
int lead = Integer.numberOfLeadingZeros(dictSize);
36
int secondBit = (dictSize >>> (30 - lead)) - 2;
38
(byte) ((19 - lead) * 2 + secondBit)
43
DEFLATE(new byte[] { (byte)0x04, (byte)0x01, (byte)0x08 }),
45
BZIP2(new byte[] { (byte)0x04, (byte)0x02, (byte)0x02 }),
47
* AES encryption with a key length of 256 bit using SHA256 for
48
* hashes - only supported when reading
50
AES256SHA256(new byte[] { (byte)0x06, (byte)0xf1, (byte)0x07, (byte)0x01 });
52
private final byte[] id;
54
private SevenZMethod(byte[] id) {
59
byte[] copy = new byte[id.length];
60
System.arraycopy(id, 0, copy, 0, id.length);
64
byte[] getProperties() {