use of com.github.zhenwei.core.crypto.macs.CMac in project LinLong-Java by zhenwei1108.
the class Mac method cmac.
public byte[] cmac(KeyEnum alg, byte[] key, byte[] source) throws WeGooCryptoException {
BlockCipher engine;
switch(alg) {
case AES_128:
case AES_256:
engine = new AESEngine();
break;
default:
engine = new SM4Engine();
}
CMac cMac = new CMac(engine);
cMac.init(new KeyParameter(key));
cMac.update(source, 0, source.length);
byte[] result = new byte[cMac.getMacSize()];
cMac.doFinal(result, 0);
return result;
}
Aggregations