我使用以下脚本解码 Base64 编码的二进制内容并将其放入字符串中然后写入文件。
byte[] decoded = slurper.signatureValue.decodeBase64();
String sigValue = new String(decoded)
def path = context.expand('${Properties#outDir}') + context.expand('${Properties#fileName}')
def myFile = new File(path)
myFile.write(sigValue)
当我使用
Notepad++
和 MIME 工具插件 解码并保存它时,输出不同并且不确定,是什么造成的不同。
以下代码生成有效(与 Notepad++ 插件相同)值:
byte[] decoded = Base64.getDecoder().decode(slurper.signatureValue);
myFile.bytes = decoded