在 Java 中以 Base45 解码和编码
Decode and encode in Base45 in Java
我非常感兴趣地关注 java 中的数字 covid 证书项目:
https://github.com/ehn-dcc-development/
更具体地说,对于 Java 和解码通行证:
https://github.com/GaetanoPiazzolla/greenpass-decode
使用此代码解码我们从 QR 码读取的 base45 字符串,我们有:
byte[] bytecompressed = Base45.getDecoder().decode(withoutPrefix);
我想对同一个字符串进行编码,所以我正在尝试以下操作:
byte[] byteCompressedNew = Base45.getEncoder().encode(bytecompressed);
但这会导致以下错误:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
Index -23 out of bounds for length 45 at
nl.minvws.encoding.Base45$Encoder.encode(Base45.java:74)
在 base45 模块的这一行代码中:
result[resultIndex++] = toBase45[value % 45];
如果你能帮助我理解我做错了什么,那就太好了。
非常感谢!
您需要将您的依赖项从版本 0.0.2 更新到 0.0.3(于 2021 年 4 月 6 日发布,并针对此问题进行了错误修复)
io.github.ehn-digital-green-development:base45:0.0.3
对于行家:
<dependency>
<groupId>io.github.ehn-digital-green-development</groupId>
<artifactId>base45</artifactId>
<version>0.0.3</version>
</dependency>
我非常感兴趣地关注 java 中的数字 covid 证书项目: https://github.com/ehn-dcc-development/
更具体地说,对于 Java 和解码通行证: https://github.com/GaetanoPiazzolla/greenpass-decode
使用此代码解码我们从 QR 码读取的 base45 字符串,我们有:
byte[] bytecompressed = Base45.getDecoder().decode(withoutPrefix);
我想对同一个字符串进行编码,所以我正在尝试以下操作:
byte[] byteCompressedNew = Base45.getEncoder().encode(bytecompressed);
但这会导致以下错误:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -23 out of bounds for length 45 at nl.minvws.encoding.Base45$Encoder.encode(Base45.java:74)
在 base45 模块的这一行代码中:
result[resultIndex++] = toBase45[value % 45];
如果你能帮助我理解我做错了什么,那就太好了。
非常感谢!
您需要将您的依赖项从版本 0.0.2 更新到 0.0.3(于 2021 年 4 月 6 日发布,并针对此问题进行了错误修复)
io.github.ehn-digital-green-development:base45:0.0.3
对于行家:
<dependency>
<groupId>io.github.ehn-digital-green-development</groupId>
<artifactId>base45</artifactId>
<version>0.0.3</version>
</dependency>