I write code to sign string android using ECDSA algorithm. Here is mycode:
String origin = txtChuoi.getText().toString();
try {
byte[] chuoiInput = origin.getBytes("UTF-8");
sig = Signature.getInstance("NONEwithECDSA","SC");
sig.initSign(privateKey);
sig.update(chuoiInput);
signatureBytes = sig.sign();
txtSign.setText(Base64.encodeToString(signatureBytes,Base64.DEFAULT));
} catch (Exception e) {
e.printStackTrace();
}
I can verify this sign string in same code app (using Java/Android). Here is my code:
String origin = txtChuoi.getText().toString();
try {
sig = Signature.getInstance("NONEwithECDSA","SC");
sig.initVerify(publicKey);
byte[] chuoiInput = origin.getBytes("UTF-8");
sig.update(chuoiInput);
txtVerify.setText(sig.verify(signatureBytes)+"");
} catch (Exception e) {
e.printStackTrace();
}
but not I want to verify it on my ubuntu server.
I have a trouble. How can I implement verify code using python? I cant write publickey code to pem file like this:
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfUnusZsShxFLUuAwwAyFAkGCq3mBy98RXIkTP8YiTO3qmL8w6eMdMadiHfdCG2emktDrUwzNmTr9nMFCFhXdGQ==
-----END PUBLIC KEY-----
But how about the Signature? And I think (but not sure) it verify on bytes[].
How python do this?