# PIYO-114 **Repository Path**: Wanzuo/piyo ## Basic Information - **Project Name**: PIYO-114 - **Description**: New Works! - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 824 - **Forks**: 0 - **Created**: 2025-10-22 - **Last Updated**: 2026-02-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ```java public class HMACUDF extends UDF { private KeyProvider keyProvider; private SecretKey hmacKey; @Override public String evaluate(String id, String keyName) { // 初始化KeyProvider(从Hadoop配置中获取) if (keyProvider == null) { keyProvider = KeyProviderLoader.getProvider(HadoopConfiguration.getInstance()); } // 获取密钥(KMS解密后返回) if (hmacKey == null) { hmacKey = keyProvider.getKey(keyName).getEncodedKey(); // 内存中临时存储 } // 计算HMAC-SHA256 Mac mac = Mac.getInstance("HmacSHA256"); mac.init(hmacKey); byte[] hash = mac.doFinal(id.getBytes(StandardCharsets.UTF_8)); // 清除内存中的密钥(减少泄露风险) Arrays.fill(hmacKey.getEncoded(), (byte) 0); return Hex.encodeHexString(hash); } } ```