如何在Dart中写入字节数组? [英] How can I write byte array in Dart?

查看:76
本文介绍了如何在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:

  1. Java: byte []
  2. Dart: Uint8List
  3. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆