修复了大量存在的问题,增加了假鸭子类型等等机制
This commit is contained in:
@@ -35,8 +35,8 @@ def main1() -> t.CInt:
|
||||
print("原文", plain)
|
||||
|
||||
# ---------- Base64 测试 ----------
|
||||
b64_out: list[t.CChar, 256]
|
||||
b64_dec: list[t.CUInt8T, 256]
|
||||
b64_out: t.CArray[t.CChar, 256]
|
||||
b64_dec: t.CArray[t.CUInt8T, 256]
|
||||
base64.b64encode(plain, b64_out)
|
||||
print("Base64 编码:", b64_out)
|
||||
dlen: t.CSizeT = base64.b64decode(b64_out, b64_dec)
|
||||
@@ -44,7 +44,7 @@ def main1() -> t.CInt:
|
||||
print("Base64 解码:", b64_dec)
|
||||
|
||||
# ---------- MD5 测试 ----------
|
||||
md5_buf: list[t.CUInt8T, hashlib.MD5_DIGEST_LEN]
|
||||
md5_buf: t.CArray[t.CUInt8T, hashlib.MD5_DIGEST_LEN]
|
||||
mctx = hashlib.md5()
|
||||
mctx.update(plain)
|
||||
mctx.final(md5_buf)
|
||||
@@ -52,7 +52,7 @@ def main1() -> t.CInt:
|
||||
print_hex(md5_buf, hashlib.MD5_DIGEST_LEN)
|
||||
|
||||
# ---------- SHA1 测试 ----------
|
||||
sha1_buf: list[t.CUInt8T, hashlib.SHA1_DIGEST_LEN]
|
||||
sha1_buf: t.CArray[t.CUInt8T, hashlib.SHA1_DIGEST_LEN]
|
||||
s1ctx = hashlib.sha1()
|
||||
s1ctx.update(plain)
|
||||
s1ctx.final(sha1_buf)
|
||||
@@ -60,7 +60,7 @@ def main1() -> t.CInt:
|
||||
print_hex(sha1_buf, hashlib.SHA1_DIGEST_LEN)
|
||||
|
||||
# ---------- SHA256 测试 ----------
|
||||
sha256_buf: list[t.CUInt8T, hashlib.SHA256_DIGEST_LEN]
|
||||
sha256_buf: t.CArray[t.CUInt8T, hashlib.SHA256_DIGEST_LEN]
|
||||
s2ctx = hashlib.sha256()
|
||||
s2ctx.update(plain)
|
||||
s2ctx.final(sha256_buf)
|
||||
@@ -68,7 +68,7 @@ def main1() -> t.CInt:
|
||||
print_hex(sha256_buf, hashlib.SHA256_DIGEST_LEN)
|
||||
|
||||
# ---------- SHA512 测试 ----------
|
||||
sha512_buf: list[t.CUInt8T, hashlib.SHA512_DIGEST_LEN]
|
||||
sha512_buf: t.CArray[t.CUInt8T, hashlib.SHA512_DIGEST_LEN]
|
||||
s5ctx = hashlib.sha512()
|
||||
s5ctx.update(plain)
|
||||
s5ctx.final(sha512_buf)
|
||||
|
||||
Reference in New Issue
Block a user