英文:
Flutter cryptography test case
问题
无法在Flutter测试中使用cryptography
库的问题是因为它在测试环境下引发了UnimplementedError
错误。但是在实际应用程序中,这个库可以正常工作。您可能无法为此库编写测试用例。
以下是您提供的代码的翻译部分:
import 'package:cryptography/cryptography.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group("Test ECDH", () {
test("generate shared secret", () async {
final algorithm = Ecdh.p256(length: 32);
final aliceKeyPair = await algorithm.newKeyPair();
});
});
}
请注意,要解决UnimplementedError
错误,您可能需要等待cryptography
库的维护者修复此问题或查看库的文档以了解是否有与测试环境兼容的解决方法。
英文:
Why can not use cryptography
on flutter test ?
import 'package:cryptography/cryptography.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group("Test ECDH", () {
test("generate shared secret", () async {
final algorithm = Ecdh.p256(length: 32);
final aliceKeyPair = await algorithm.newKeyPair();
});
});
}
i receive this error :
/opt/flutter/bin/flutter --no-color test --machine --start-paused test/custom_test.dart
Testing started at 9:24 PM ...
package:cryptography/src/dart/ecdh.dart 53:5 DartEcdh.newKeyPair
test/custom_test.dart 8:44 main.<fn>.<fn>
UnimplementedError
this simple code does work on real application (web or mobile ...)
but i can not write test case for this library !
Note: I test this code on Linux Ubuntu 22.04
答案1
得分: 1
在纯Dart中实现了Ecdh(P256、P384、P521)。目前,如果您尝试使用它,它会抛出UnimplementedError。
显然,该包不起作用(在Mac上也尝试过)。
也许在Web版本上它可以运行,使用Web Cryptography API。
英文:
> Ecdh (P256, P384, P521) implementation in pure Dart. Currently it
> throws UnimplementedError if you try to use it.
Apparently, the package doesn't work. (Tried on Mac too)
Maybe on a web version it could run, With the Web Cryptography API.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论