0

我想tink为我的应用程序使用 Google 库。我使用 android 绑定了我的代码ndk。但是,我无法tink使用bazel. 我已经在 github ( https://github.com/google/tink ) 上尝试了他们的示例。此外,我没有任何经验bazel。因此,如果有人知道如何以tink任何方式构建 Google 库,我也对这些选项持开放态度。

我在用:

  • Ubuntu 20.04
  • 巴泽尔 3.1.0
  • gcc 版本是 9.3.0

我试图关注https://github.com/google/tink/blob/master/examples/cc/helloworld/README.md但它导致了一个错误:

bazel build ...

Starting local Bazel server and connecting to it...
ERROR: error loading package 'javascript/aead/internal': Unable to find package for @npm//@bazel/typescript:index.bzl: The repository '@npm' could not be resolved.
INFO: Elapsed time: 6.455s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded)
    currently loading: javascript/binary ... (6 packages)
4

1 回答 1

0

编写时README.md,整个项目位于单个Bazel 工作区中。现在examples子目录是它自己独立的工作区,所以你需要cd在执行之前进入它bazel

正确说明:

# Build the code.
git clone https://github.com/google/tink
cd tink/examples/cc
bazel build ...

# Create some input.
echo "some plaintext" > foo.txt

# Encrypt.
./bazel-bin/helloworld/hello_world ./helloworld/aes128_gcm_test_keyset_json.txt \
    encrypt foo.txt "some aad" foo.encrypted

# Decrypt.
./bazel-bin/helloworld/hello_world ./helloworld/aes128_gcm_test_keyset_json.txt \
    decrypt foo.encrypted "some aad" foo-decrypted.txt

# Inspect the output.
cat foo-decrypted.txt

请注意,C++ 实现还支持使用 CMake,这可能更容易满足您的目的。

于 2021-03-05T10:03:51.043 回答