# as-hmac-sha2 **Repository Path**: mirrors_jedisct1/as-hmac-sha2 ## Basic Information - **Project Name**: as-hmac-sha2 - **Description**: SHA-256, SHA-512, HMAC-SHA-256, HMAC-SHA-512 for AssemblyScript. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-05-14 - **Last Updated**: 2025-09-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # HMAC-SHA-256 and HMAC-SHA-512 for AssemblyScript Self-contained implementations of SHA-256, SHA-512, HMAC-SHA-256 and HMAC-SHA-512 for AssemblyScript. Simple hashing: ```typescript let msg = Uint8Array.wrap(String.UTF8.encode("test")); let h = Sha256.hash(msg); ``` Chunked input: ```typescript let st = new Sha256(); st.update(msg1); st.update(msg2); let h = st.final(); ``` HMAC: ```typescript let msg = Uint8Array.wrap(String.UTF8.encode("message")); let key = Uint8Array.wrap(String.UTF8.encode("key")); let mac = Sha256.hmac(msg, key); ``` Constant-time check for equality: ```typescript let ok = verify(mac, expected_mac); ``` Constant-time hexadecimal encoding/decoding: ```typescript let hex = bin2hex(h); let bin = hex2bin(hex); ```