# 错误：requirements.txt 中的行具有无效的哈希格式：'sha256:abc123...' 哈希必须采用 'sha256:...' 格式（无空格，小写）。

- **ID:** `pip/requirements-hash-invalid-line`
- **领域:** pip
- **类别:** data_error
- **错误码:** `ERROR`
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

requirements.txt 文件中的哈希值格式错误，例如包含大写字母、空格或错误的算法前缀，导致 pip 在哈希验证期间拒绝整行。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pip 23.3 | active | — | — |
| pip 24.0 | active | — | — |
| pip 24.1 | active | — | — |

## 解决方案

1. ```
   使用 pip 内置工具重新生成哈希：pip hash /path/to/package.whl
   ```
2. ```
   手动修正 requirements.txt 中的哈希格式为小写并用冒号分隔：sha256:abcdef1234567890...
   ```
3. ```
   使用哈希生成脚本：python -c "import hashlib; print('sha256:' + hashlib.sha256(open('package.whl','rb').read()).hexdigest())"
   ```

## 无效尝试

- **** — Pip strictly parses the hash format; any deviation from 'algorithm:hexdigest' causes rejection. (50% 失败率)
- **** — Without the algorithm prefix, pip cannot determine which hash function to use for verification. (80% 失败率)
