diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-01 05:26:16 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-01 18:41:11 +0900 |
| commit | 06d2c5c884eee0b5b663730f4d379a7ceae3a8e4 (patch) | |
| tree | 5cd768e0bdad3f8a056dd9b047de363963315135 /crates/shirabe-php-shim/src/hash.rs | |
| parent | b8d46b0495d00815a699932ced0b43955c949ab9 (diff) | |
| download | php-shirabe-06d2c5c884eee0b5b663730f4d379a7ceae3a8e4.tar.gz php-shirabe-06d2c5c884eee0b5b663730f4d379a7ceae3a8e4.tar.zst php-shirabe-06d2c5c884eee0b5b663730f4d379a7ceae3a8e4.zip | |
feat(php-shim): implement Phar/PharData and the zlib/bzip2 functions
Adopt the tar, flate2, and bzip2 crates to fill in the phar.rs and
compress.rs todos: PharData tar/zip reading, building, and whole-archive
compression, plus a native .phar reader that follows the php.net
file-format manual and verifies hash-based signatures. Callers now
propagate the constructor/extract errors PHP throws, and fwrite accepts
byte strings so gzread no longer needs lossy UTF-8.
The native .phar writing API stays todo!() (no call sites; Composer's
Compiler is not ported) and OPENSSL phar signatures are accepted
unverified (TODO(phase-c)).
This unblocks Tar::getComposerJson and the tar/phar/gzip downloaders;
tar_test (7), artifact_repository_test (2), and phar_archiver_test zip
(1) are un-ignored. The archive command itself still panics because
ArchiveManager::archive always generates glob excludes whose look-ahead
regexes the regex crate cannot compile; converting those patterns to
regex-compatible ones is a separate, still-undecided work item.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src/hash.rs')
| -rw-r--r-- | crates/shirabe-php-shim/src/hash.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/crates/shirabe-php-shim/src/hash.rs b/crates/shirabe-php-shim/src/hash.rs index d77cc0a7..d98dcb22 100644 --- a/crates/shirabe-php-shim/src/hash.rs +++ b/crates/shirabe-php-shim/src/hash.rs @@ -14,11 +14,12 @@ pub fn hash_file(algo: &str, filename: impl AsRef<std::path::Path>) -> Option<St Some(bin2hex(&calculate_hash(algo, &data))) } -fn calculate_hash(algo: &str, data: &[u8]) -> Vec<u8> { +pub(crate) fn calculate_hash(algo: &str, data: &[u8]) -> Vec<u8> { match algo { "md5" => md5::compute(data).0.to_vec(), "sha1" => sha1::Sha1::digest(data).to_vec(), "sha256" => sha2::Sha256::digest(data).to_vec(), + "sha512" => sha2::Sha512::digest(data).to_vec(), "xxh3" => twox_hash::XxHash3_64::oneshot(data).to_be_bytes().to_vec(), _ => panic!("unsupported hash algorithm: {}", algo), } |
