hello everyone !
i am ysing this code :
i get this error log :
what is the maximum length of the password string
i am ysing this code :
B4X:
Sub EncryptText(text As String, password As String) As Byte()
Dim c As B4XCipher
Return c.Encrypt(text.GetBytes("utf8"), password)
End Sub
Sub DecryptText(EncryptedData() As Byte, password As String) As String
Dim c As B4XCipher
Dim b() As Byte = c.Decrypt(EncryptedData, password)
Return BytesToString(b, 0, b.Length, "utf8")
End Sub
Dim encryptedData() As Byte = EncryptText("MyString To obfuscate", "Xu54Nh4")
Log(DecryptText(encryptedData, "Xu54Nh4"))
i get this error log :
B4X:
2022-02-04 16:35:24.692:INFO::main: Logging initialized @174ms to org.eclipse.jetty.util.log.StdErrLog
2022-02-04 16:35:24.883:INFO:oejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_311-b11
2022-02-04 16:35:24.944:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2022-02-04 16:35:24.944:INFO:oejs.session:main: No SessionScavenger set, using defaults
2022-02-04 16:35:24.948:INFO:oejs.session:main: node0 Scavenging every 600000ms
2022-02-04 16:35:24.989:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@57fffcd7{/,file:///D:/Waldemar%20Lima/Documents/PROJETOS-LICITA%C3%87%C3%83O/SOFT-CHAMADOS/Server/Soft-Chamados/Objects/www/,AVAILABLE}
2022-02-04 16:35:25.019:INFO:oejs.AbstractNCSARequestLog:main: Opened D:\Waldemar Lima\Documents\PROJETOS-LICITAÇÃO\SOFT-CHAMADOS\Server\Soft-Chamados\Objects\logs\b4j-2022_02_04.request.log
2022-02-04 16:35:25.360:INFO:oejs.AbstractConnector:main: Started ServerConnector@4b952a2d{HTTP/1.1,[http/1.1]}{0.0.0.0:8092}
2022-02-04 16:35:25.361:INFO:oejs.Server:main: Started @845ms
java.lang.RuntimeException: org.bouncycastle.crypto.DataLengthException: last block incomplete in decryption
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:138)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:130)
at anywheresoftware.b4j.object.JServlet.Handle(JServlet.java:110)
at anywheresoftware.b4j.object.JServlet.doGet(JServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:531)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.bouncycastle.crypto.DataLengthException: last block incomplete in decryption
at org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher.doFinal(Unknown Source)
at anywheresoftware.b4x.object.B4XEncryption.Decrypt(B4XEncryption.java:73)
at b4j.example.index._handle(index.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
... 29 more
what is the maximum length of the password string