Base64 使用 Groovy 脚本解码二进制内容

问题描述 投票:0回答:1

我使用以下脚本解码 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 工具插件 解码并保存它时,输出不同并且不确定,是什么造成的不同。

groovy base64 soapui decode binary-data
1个回答
0
投票

以下代码生成有效(与 Notepad++ 插件相同)值:

byte[] decoded = Base64.getDecoder().decode(slurper.signatureValue);
myFile.bytes = decoded
© www.soinside.com 2019 - 2024. All rights reserved.