如何在Dart中写入字节数组? [英] How can I write byte array in Dart?
问题描述
如何在Dart中编写字节数组?我想实现此功能,但这是Java代码,其中包含 byte []
.也可以用Dart编写吗?
How do I write a byte array in Dart? I want to implement this function, but it is Java code with byte[]
in it. Can it be written in Dart as well?
public static byte[] encrypt(byte[] key, byte[] data) throws Exception {
try {
return performCipher(Cipher.ENCRYPT_MODE, key, data);
} catch (Exception e) {
throw new Exception(e);
}
}
推荐答案
您正在寻找的是 Uint8List
.它等效于Dart中Java的 byte []
.每个单个值在另一种语言中都具有等效项,因此几种语言中的 byte []
类似于:
What you are looking for is Uint8List
. It is the equivalent of byte[]
of Java in Dart. Every single value has an equivalent in another language, so byte[]
in a few languages is like:
- Java:
byte []
- Dart:
Uint8List
- iOS:
FlutterStandardTypedData->typedDataWithBytes
我建议查看文档以了解更多信息: https://flutter.dev/docs/development/platform-integration/platform-channels#codec
I recommend looking at the documentation for more: https://flutter.dev/docs/development/platform-integration/platform-channels#codec
这篇关于如何在Dart中写入字节数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!