Created
March 22, 2017 15:44
-
-
Save renholm/b8c918c9c469b740eff6f3b5b239945e to your computer and use it in GitHub Desktop.
Generate the hash for an EMV CA public key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.common.hash.HashCode; | |
import com.google.common.hash.Hashing; | |
import com.google.common.io.BaseEncoding; | |
import java.io.ByteArrayOutputStream; | |
import java.io.IOException; | |
public class GenerateEMVCAPubKeyHash { | |
public static void main(String[] args) throws IOException { | |
byte[] rid = BaseEncoding.base16().decode(""); | |
byte[] caPublicKeyIndex = BaseEncoding.base16().decode(""); | |
byte[] caPublicKeyMod = BaseEncoding.base16().decode(""); | |
byte[] caPublicKeyExp = BaseEncoding.base16().decode(""); | |
final ByteArrayOutputStream stream = new ByteArrayOutputStream(rid.length + caPublicKeyIndex.length + caPublicKeyMod.length + caPublicKeyExp.length); | |
stream.write(rid, 0, rid.length); | |
stream.write(caPublicKeyIndex, 0, caPublicKeyIndex.length); | |
stream.write(caPublicKeyMod, 0, caPublicKeyMod.length); | |
stream.write(caPublicKeyExp, 0, caPublicKeyExp.length); | |
final HashCode signature = Hashing.sha1().hashBytes(stream.toByteArray()); | |
System.out.println(signature.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment