Python Crypto Singature do not support Android???

Frank Liou fk26541598fk at gmail.com
Fri Sep 5 09:23:51 CEST 2014


Sorry!!

here is my code

python :

msg = '123'
msg = msg.encode('utf-8')
digest = SHA.new(msg).digest()
signature = APP_key_Private.sign(digest, '')

signature like: (3313609575189770456309776952388055366479183814159935747487353823698464644111856144652004406811762087026328804664486509214841694613481763164909855307029962363047099944520695429504224843583313164533334332743470132105629096577439312314814238554088472504815623363978006284897433036223490623530076474911740732410,)


and android :

InputStream inPrivate = getResources().getAssets().open("PR1.pem");
PrivateKey privateKey = RSAUtils.loadPrivateKey(inPrivate);
Log.d("privateKey------",privateKey.toString());

 byte[] a = Sign.digest("123".getBytes());
  String test_a_to64  = Base64.encodeToString(a,Base64.DEFAULT);
  Log.d("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX------",test_a_to64);
  Log.d("sdfgserthwrthhsrethwegerg------",Arrays.toString(a));

String sdf = Sign.sign(a,privateKey);
 Log.d("000000000000000000000------",Arrays.toString(sdf.getBytes()));

Android like:


[34, 68, 28, 72, -43, 7, -64, -127, -119, -44, 61, -53, -22, 112, -74, -122, -19, -127, -120, -43, 1, -55, 66, -47, -63, -128, 104, -97, 104, 65, -48, -120, -50, 117, 85, 86, -33, 37, -77, -26, -46, -59, -43, -42, -79, -9, -78, -26, -25, 5, 4, -104, 95, -120, -73, 123, 70, -11, 56, -10, -99, -126, -30, -3, -63, 42, 45, 33, 36, 23, -52, 10, -4, -17, 8, 82, -61, 74, 43, -5, 44, 29, 127, 78, 100, -88, -24, -61, -24, 3, -105, 4, 117, 71, 41, 74, 99, 23, 68, 112, -8, -105, 67, -68, -115, -27, -24, 114, -108, 28, 15, -85, -77, 49, -110, -10, -83, -58, -27, 34, 90, -52, 71, -72, 73, -5, -2, -56]



please help



More information about the Python-list mailing list