搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.0

crypto_keys_plus

一個用於執行加密簽名/驗證以及加密/解密的程式庫。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
8萬
喜歡數
3
Pub 分數
150

安裝套件

flutter pub add crypto_keys_plus

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個專為加密操作(如簽名、驗證、加密和解密資料)設計的 Flutter/Dart 套件。它提供了一種安全且跨平台的解決方案,可在 Android、iOS、Web、macOS、Windows 和 Linux 上處理敏感資訊。此套件以簡單性為核心,讓開發者無需深入掌握密碼學知識即可實現強大的安全功能。該庫在可用時利用底層原生加密 API,確保效能並符合各平台特定的安全標準。

適用情境

  • 安全資料傳輸
  • 數位簽章驗證
  • 端對端加密
  • 身份驗證令牌保護
  • 敏感數據的安全本地存儲
  • 遵守資料隱私法規

主要特色

  • 跨平台加密支援
  • 用於簽名和加密的簡單 API
  • 與原生加密庫整合
  • 對多個平台的支援
  • 安全金鑰管理
  • 開源且持續維護

適合對象

  • 開發安全應用的開發者
  • 需要資料完整性的應用
  • 處理使用者驗證的應用程式
  • 需要加密通訊的項目
  • 優先考慮合規性和安全性

使用建議

  • 需要了解基本的密碼學概念
  • 依賴於平台特定的加密實現
  • 不適合高效率加密作業負載
  • 必須遵循密鑰管理最佳實踐
  • 除了基本用法外,文件有限

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Build Status :heart: sponsor

A library for doing cryptographic signing/verifying and encrypting/decrypting.

It uses pointycastle under the hood, but exposes a more convenient api.

Usage

Signing

A simple usage example:

import 'package:crypto_keys/crypto_keys.dart';
import 'dart:typed_data';

main() {
  // Create a key pair from a JWK representation
  var keyPair = new KeyPair.fromJwk({
    "kty": "oct",
    "k": "AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75"
        "aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow"
  });

  // A key pair has a private and public key, possibly one of them is null, if
  // required info was not available when construction
  // The private key can be used for signing
  var privateKey = keyPair.privateKey;

  // Create a signer for the key using the HMAC/SHA-256 algorithm
  var signer = privateKey.createSigner(algorithms.signing.hmac.sha256);

  // Sign some content, to be integrity protected
  var content = "It's me, really me";
  var signature = signer.sign("It's me, really me".codeUnits);

  print("Signing '$content'");
  print("Signature: ${signature.data}");

  // The public key can be used for verifying the signature
  var publicKey = keyPair.publicKey;

  // Create a verifier for the key using the specified algorithm
  var verifier = publicKey.createVerifier(algorithms.signing.hmac.sha256);

  var verified =
      verifier.verify(new Uint8List.fromList(content.codeUnits), signature);
  if (verified)
    print("Verification succeeded");
  else
    print("Verification failed");
}
Encryption

A simple usage example:


import 'package:crypto_keys/crypto_keys.dart';
import 'dart:typed_data';

main() {
  // Generate a new random symmetric key pair
  var keyPair = new KeyPair.generateSymmetric(128);

  // Use the public key to create an encrypter with the AES/GCM algorithm
  var encrypter =
      keyPair.publicKey.createEncrypter(algorithms.encryption.aes.gcm);

  // Encrypt the content with an additional authentication data for integrity
  // protection
  var content = "A very secret text";
  var aad = "It is me";
  var v = encrypter.encrypt(new Uint8List.fromList(content.codeUnits),
      additionalAuthenticatedData: new Uint8List.fromList(aad.codeUnits));

  print("Encrypting '$content'");
  print("Ciphertext: ${v.data}");
  print("Authentication tag: ${v.authenticationTag}");

  // Use the private key to create the decrypter
  var decrypter =
      keyPair.privateKey.createEncrypter(algorithms.encryption.aes.gcm);

  // Decrypt and verify authentication tag
  var decrypted = decrypter.decrypt(v);

  print("Decrypted text: '${new String.fromCharCodes(decrypted)}'");
}

Features and bugs

Please file feature requests and bugs at the issue tracker.

Sponsor

Creating and maintaining this package takes a lot of time. If you like the result, please consider to :heart: sponsor. With your support, I will be able to further improve and support this project.

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案