Lesamnta-LWLesamnta-LW is an Lightweight Cipher 256-bit hash function [paper]. It uses the methods used in the AES-based block cipher The focus of Lesamnta-LW is on a compact and fast hashing for lightweight application with \(2^{120}\) security level. The primary target is for 8-bit CPUs for short message hashing. |
Code
The following shows a C++ version of the code:
// https://asecuritysite.com/encryption/lw // https://github.com/kuwakado/Lesamnta-LW/blob/master/main.c #define _GNU_SOURCE #include#include #include #include #include #include #include "lesamnta-LW.h" #define NELMS(a) (sizeof(a)/sizeof(a[0])) int main(int argc, char *argv[]) { BitSequence data[256] = "abc"; puts("Lesamnta-LW"); DataLength bytelen = strlen(data); DataLength databitlen = bytelen * 8; BitSequence hashval[LESAMNTALW_HASH_BITLENGTH / 8]; Hash(LESAMNTALW_HASH_BITLENGTH, data, databitlen, hashval); printf("message: "); for (int i = 0; i < bytelen; ++i) { printf("%02x", data[i]); } printf("\n"); printf("hashval: "); for (int i = 0; i < LESAMNTALW_HASH_BITLENGTH / 8; ++i) { printf("%02x", hashval[i]); } printf("\n"); return 0; }