Android Question error with rsa

samperizal

Active Member
Licensed User
Regards.
I have the following problem with RSA the public and private key put them in a table and try to assign the following error:
java.security.spec.InvalidKeySpecException: java.lang.RuntimeException: error: 0D0680A8: asn1 encoding routines: ASN1_CHECK_TLEN: wrong tagis


this correct code?
Dim kpg Dim KeyPairGenerator
Dim SPubKey (0) As Byte
Dim SPrivate (0) As Byte
Dim Datos_Clave (0) As Byte
Dim data (0) As Byte
SPubKey = Bconv.StringToBytes (p1.GetString ("Post"), "UTF8")
SPrivate = Bconv.StringToBytes (p1.GetString ("Private"), "UTF8")
Datos_Clave = Bconv.StringToBytes (p1.GetString ("Key"), "UTF8")
cclave.Initialize ("RSA")kpg.Initialize ("RSA", 512)

kpg.PublicKeyFromBytes (SPubKey)
kpg.PrivateKeyFromBytes (SPrivate)

data = cclave.Decrypt (Datos_Clave, kpg.PrivateKey, False)

Msgbox (Bconv.StringFromBytes (data, "UTF8"), "Decrypted")

Thank you
 

samperizal

Active Member
Licensed User
solved

change


SPrivate = Bconv.StringToBytes (p1.GetString ("Private"), "UTF8")

by

SPubKey = Bconv.HexToBytes (p1.GetString ("Post"))
 
Top