调整目录结构

This commit is contained in:
zcy
2025-09-09 10:36:33 +08:00
parent 2549f565b4
commit 088c0c00f6
772 changed files with 7789 additions and 1 deletions

View File

@@ -0,0 +1,66 @@
//package com.cscn;
//
///**
// * 演示主函数
// */
//public final class Zuc256Demo {
//
// public static void main(String[] args) {
// // 1. 明文
// byte[] plaintext = "ZUC256对称加解密测试:1234567890".getBytes();
// int plaintextLen = plaintext.length;
// System.out.println("明文: " + new String(plaintext));
// printHex("明文(十六进制)", plaintext, plaintextLen);
//
// // 2. 密钥(32字节ASCII)
// byte[] key = "0123456789abcdef0123456789abcdef".getBytes();
// printHex("密钥", key, 32);
//
// // 3. 初始向量(25字节ASCII)
// byte[] inputIv25Byte = "0123456789abcdefg01234567".getBytes();
// byte[] iv = new byte[23];
// extractIv(inputIv25Byte, iv);
// printHex("提取后的IV", iv, 23);
//
// // 4. 分配加密/解密缓冲区
// byte[] ciphertext = new byte[plaintextLen];
// byte[] decryptedtext = new byte[plaintextLen];
//
// // 5. 加密
// Zuc256State stateEnc = new Zuc256State();
// Zuc256Core.initState(stateEnc, key, iv);
// zuc256Crypt(stateEnc, plaintext, plaintextLen, ciphertext);
// printHex("密文", ciphertext, plaintextLen);
//
// // 6. 解密(重新初始化状态)
// Zuc256State stateDec = new Zuc256State();
// Zuc256Core.initState(stateDec, key, iv);
// zuc256Crypt(stateDec, ciphertext, plaintextLen, decryptedtext);
// printHex("解密后", decryptedtext, plaintextLen);
// System.out.println("解密文本: " + new String(decryptedtext));
//
// // 7. 验证结果
// if (Arrays.equals(plaintext, decryptedtext)) {
// System.out.println("=== 测试成功: 解密结果与明文一致 ===");
// } else {
// System.out.println("=== 测试失败: 解密结果与明文不一致 ===");
// }
// }
//
// // 一次性加密
// public static void zuc256Crypt(Zuc256State state, byte[] in, int inlen, byte[] out) {
// if (state == null || in == null || out == null) return;
//
// Zuc256EncryptCtx ctx = new Zuc256EncryptCtx(state);
//
// // 执行加解密
// ctx.update(in, inlen, out);
// int remainingOffset = (inlen / 4) * 4;
// byte[] finishOut = new byte[out.length - remainingOffset];
// if (finishOut.length > 0) {
// System.arraycopy(out, remainingOffset, finishOut, 0, finishOut.length);
// }
// ctx.finish(finishOut);
// System.arraycopy(finishOut, 0, out, remainingOffset, finishOut.length);
// }
//}