Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77577 > unrolled thread
| Started by | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| First post | 2014-09-05 00:02 -0700 |
| Last post | 2014-09-05 17:47 +1000 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.python
Python Crypto Singature do not support Android??? Frank Liou <fk26541598fk@gmail.com> - 2014-09-05 00:02 -0700
Re: Python Crypto Singature do not support Android??? Chris Angelico <rosuav@gmail.com> - 2014-09-05 17:11 +1000
Re: Python Crypto Singature do not support Android??? Frank Liou <fk26541598fk@gmail.com> - 2014-09-05 00:23 -0700
Re: Python Crypto Singature do not support Android??? Chris Angelico <rosuav@gmail.com> - 2014-09-05 17:47 +1000
| From | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| Date | 2014-09-05 00:02 -0700 |
| Subject | Python Crypto Singature do not support Android??? |
| Message-ID | <614897cb-6a2f-4059-a713-05c0cd2b3cd5@googlegroups.com> |
I use Privatekey sign a signature by android and then send to python python can't use public key to verify and python signature result all is number but android is number and english words is that no support??
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-09-05 17:11 +1000 |
| Message-ID | <mailman.13784.1409901074.18130.python-list@python.org> |
| In reply to | #77577 |
On Fri, Sep 5, 2014 at 5:02 PM, Frank Liou <fk26541598fk@gmail.com> wrote: > I use Privatekey sign a signature by android > > and then send to python > > python can't use public key to verify > > and > > python signature result all is number > > but > > android is number and english words > > is that no support?? It would help if you showed us (a) the code, (b) the two different results, and (c) what you're expecting to see. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| Date | 2014-09-05 00:23 -0700 |
| Message-ID | <5bacfff0-246f-4c97-b8ba-5f6ce45acf29@googlegroups.com> |
| In reply to | #77577 |
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
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-09-05 17:47 +1000 |
| Message-ID | <mailman.13786.1409903284.18130.python-list@python.org> |
| In reply to | #77579 |
On Fri, Sep 5, 2014 at 5:23 PM, Frank Liou <fk26541598fk@gmail.com> wrote:
> here is my code
>
> python :
>
> msg = '123'
> msg = msg.encode('utf-8')
> digest = SHA.new(msg).digest()
> signature = APP_key_Private.sign(digest, '')
That code is incomplete, I can't run it. Ditto your Java code. But
what seems to be happening is that you're getting data back in two
very different formats, plus you're generating one signature based on
a UTF-8 stream and one based on a Base-64 stream. Start by writing
*simple* code that does what you want, and then porting that to the
other language exactly.
Also, please don't use Google Groups, or if you must, please remember
to include context.
ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web