Android Question RSA with b4a

Discussion in 'Android Questions' started by omidaghakhani1368, Jul 30, 2015.

  1. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Hi
    I can encrypt data with algoritm RSA with below code
    but i cannot decrypt data
    (public and private key created with php)

    Code:
    Dim su As StringUtils
        
    Dim data() As Byte = su.DecodeBase64(File.ReadString(File.DirAssets,"public.txt"))
        
    Dim p1 As KeyPairGenerator
        
    Dim c1 As Cipher
       
        p1.Initialize(
    "RSA",1024)
        p1.PublicKeyFromBytes(data)
       
        c1.Initialize(
    "RSA/ECB/PKCS1Padding")
       
        
    Dim d1() As Byte
        d1 = c1.Encrypt(r1.StringToBytes(
    "ali","UTF8"),p1.PublicKey,False)
       
        
    Dim res As String
        res = su.EncodeBase64(d1)
     
    Alexander Stolte likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice