Hi!
How can I add a line of the file to a string.
The string makes an HTTP request.
This is my code:
If use one string, exemple:
url = "http://www.site.com"
Its OK!
But my exemple not work!
Thanks!
How can I add a line of the file to a string.
The string makes an HTTP request.
This is my code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("noticias")
conexao.Initialize(0, "")
conexao.Listen
Dim pubkey(0) As Byte
Dim prvkey(0) As Byte
Dim data(0) As Byte
Dim formats(0) As String
Dim Reader As TextReader
Dim kpg As KeyPairGenerator
Dim c As Cipher
c.Initialize("RSA")
kpg.Initialize("RSA", 512) ' the maximum number of bytes that can be encrypted increase with key size
kpg.GenerateKey
formats = kpg.Formats
data = kpg.PublicKeyToBytes ' check we can round trip the public key as X509
Msgbox(formats(0) & CRLF & Bconv.HexFromBytes(data), "Public key " & data.Length & " bytes")
kpg.PublicKeyFromBytes(data)
data = kpg.PrivateKeyToBytes ' check we can round trip the public key as PKCS8
Msgbox(formats(1) & CRLF & Bconv.HexFromBytes(data), "Private key " & data.Length & " bytes")
kpg.PrivateKeyFromBytes(data)
Reader.Initialize(File.OpenInput(File.DirRootExternal, "crypto.mdl")) 'Open file with url encrypted
clear = Reader.ReadLine ' read the line
Reader.Close 'close file
data = Bconv.StringToBytes(clear, "UTF8")
data = c.Encrypt(data, kpg.PublicKey, False)
data = c.Decrypt(data, kpg.PrivateKey, False) ' decrypted in the theory
link1 = Bconv.StringFromBytes(data, "UTF8") ' variable to with url decrypted
Dim job3 As HttpJob
job3.Initialize("Job3", Me)
job3.Download(link1)
End Sub
If use one string, exemple:
url = "http://www.site.com"
Its OK!
But my exemple not work!
Thanks!