Java Code Examples for org.spongycastle.crypto.macs.HMac#doFinal()
The following examples show how to use
org.spongycastle.crypto.macs.HMac#doFinal() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Cryptograph.java From SightRemote with GNU General Public License v3.0 | 5 votes |
private static byte[] getHmac(byte[] secret, byte[] data, Digest algorithm) { HMac hmac = new HMac(algorithm); hmac.init(new KeyParameter(secret)); byte[] result = new byte[hmac.getMacSize()]; hmac.update(data, 0, data.length); hmac.doFinal(result, 0); return result; }
Example 2
Source File: CryptoPrimitivesAndroid.java From Clusion with GNU General Public License v3.0 | 5 votes |
public static byte[] generateHmac(byte[] key, String msg) throws UnsupportedEncodingException { HMac hmac = new HMac(new SHA256Digest()); byte[] result = new byte[hmac.getMacSize()]; byte[] msgAry = msg.getBytes("UTF-8"); hmac.init(new KeyParameter(key)); hmac.reset(); hmac.update(msgAry, 0, msgAry.length); hmac.doFinal(result, 0); return result; }
Example 3
Source File: CryptoPrimitivesAndroid.java From Clusion with GNU General Public License v3.0 | 5 votes |
public static byte[] generateHmac(byte[] key, byte[] msg) throws UnsupportedEncodingException { HMac hmac = new HMac(new SHA256Digest()); byte[] result = new byte[hmac.getMacSize()]; hmac.init(new KeyParameter(key)); hmac.reset(); hmac.update(msg, 0, msg.length); hmac.doFinal(result, 0); return result; }
Example 4
Source File: CryptoPrimitivesAndroid.java From Clusion with GNU General Public License v3.0 | 5 votes |
public static byte[] generateHmac512(byte[] key, String msg) throws UnsupportedEncodingException { HMac hmac = new HMac(new SHA512Digest()); byte[] result = new byte[hmac.getMacSize()]; byte[] msgAry = msg.getBytes("UTF-8"); hmac.init(new KeyParameter(key)); hmac.reset(); hmac.update(msgAry, 0, msgAry.length); hmac.doFinal(result, 0); return result; }
Example 5
Source File: Cryptograph.java From AndroidAPS with GNU Affero General Public License v3.0 | 5 votes |
private static byte[] getHmac(byte[] secret, byte[] data, Digest algorithm) { HMac hmac = new HMac(algorithm); hmac.init(new KeyParameter(secret)); byte[] result = new byte[hmac.getMacSize()]; hmac.update(data, 0, data.length); hmac.doFinal(result, 0); return result; }