小编fas*_*mat的帖子

将Java解密代码迁移到Golang

在过去的几天里,我一直在努力将Java代码迁移到Golang,现在我陷入困境.这是可用的Java代码:

final Key k = new SecretKeySpec(keyString.getBytes(), "AES");
Cipher c = Cipher.getInstance("AES");
c.init(Cipher.DECRYPT_MODE, k);

final InputStream in = new BufferedInputStream(new FileInputStream(fileNameToDecrypt));
final CipherInputStream instream = new CipherInputStream(in, c);

if (instream.read() != 'B') {
    System.out.println("Error");
}

if (instream.read() != 'Z') {
    System.out.println("Error");
}

final CBZip2InputStream zip = new CBZip2InputStream(instream);
Run Code Online (Sandbox Code Playgroud)

我在Golang中的实现:

c, _ := aes.NewCipher([]byte(keyString))
// IV must be defined in golang
iv := []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
d := …
Run Code Online (Sandbox Code Playgroud)

java aes go bzip2

8
推荐指数
1
解决办法
1643
查看次数

标签 统计

aes ×1

bzip2 ×1

go ×1

java ×1