패키지, 저장소 및 앱 카테고리 검색

패키지 상세v3.1.1

aes_crypt_null_safe

AES Crypt 파일 형식으로 파일, 일반 텍스트 및 이진 데이터를 암호화/복호화하는 데 사용할 수 있는 Dart 암호화 라이브러리입니다. 모든 플랫폼(웹 포함)을 지원합니다.

AndroidiOSmacOSWindowsLinux
30일 다운로드
6.1천
좋아요
34
Pub 점수
160

패키지 설치

flutter pub add aes_crypt_null_safe

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

AES Crypt 파일 형식을 사용하여 파일, 일반 텍스트 및 바이너리 데이터를 안전하게 암호화하고 복호화할 수 있는 Dart 암호화 라이브러리입니다. 크로스 플랫폼 사용을 위해 설계되어 Android, iOS, macOS, Windows, Linux 및 웹 환경을 지원합니다. null 안정성을 보장하며 강력한 암호화 표준을 사용하여 민감한 데이터를 다루기 위한 간단한 API를 제공합니다. 안전한 데이터 저장 또는 전송이 필요한 애플리케이션에 적합합니다.

사용 사례

  • 민감한 사용자 데이터 암호화
  • 구성 파일 보호
  • 파일 전송 보호
  • 암호화된 자격 증명 저장
  • 웹 및 모바일 앱 데이터 보안

주요 기능

  • AES Crypt 형식 지원
  • 널 안전한 Dart 구현
  • 크로스 플랫폼 호환성
  • 파일 및 텍스트 암호화
  • 보안 바이너리 데이터 처리

적합한 대상

  • 데이터 암호화가 필요한 모바일 앱
  • 보안 저장 기능을 갖춘 웹 애플리케이션
  • 민감한 정보를 처리하는 데스크톱 애플리케이션
  • 다중 플랫폼에서 Flutter를 사용하는 개발자
  • AES 기준 준수를 요구하는 프로젝트

고려 사항

  • 신중한 키 관리가 필요합니다
  • 고성능 대량 암호화에 적합하지 않습니다
  • AES 암호 형식으로 제한됨
  • 외부 암호화 라이브러리에 의존합니다
  • 암호 해독 실패 시 예외를 처리해야 합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

aes_crypt

Note

This package is a null-safe fork of the aes_crypt package, providing the same powerful AES encryption functionality with full null safety support for modern Dart and Flutter applications.

Introduction

aes_crypt is a library for Dart and Flutter developers that uses 256-bit AES algorithm to encrypt/decrypt files, plain text and binary data. It is fully compatible with the AES Crypt file format. It can be used to integrate AES Crypt functionality into your own Dart or Flutter applications. All algorithms are implemented in pure Dart and work in all platforms.

aes_crypt writes and reads version 2 of the AES Crypt file specification. Backwards compatibility with reading the version 1 is implemented but untested. Output .aes files are fully compatible with any software using the AES Crypt standard file format. This library is accompanied by clients and libraries for different operating systems and programming languages. For more information about AES Crypt and AES Crypt compatible applications for other platforms, please visit AESCrypt's official website.

Features

  • 256-bit AES encryption format.
  • File-to-file encryption and decryption.
  • Memory-to-file encryption, file-to-memory decryption.
  • Password can be in Unicode (like "密碼 パスワード пароль كلمة السر").
  • Support for asynchronous file system reading/writing.
  • Encrypted files have .aes extension which clients on other operating systems recognize.
  • Compatible software available for Windows, Linux, Mac OS, Android and iOS (https://www.aescrypt.com/download/).

Usage

In your Dart code add the following import:

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

Initialization:

var crypt = AesCrypt('my cool password');

or

var crypt = AesCrypt();
crypt.setPassword('my cool password');

Optionally you can set overwrite mode for the file write operations:

// Overwrites the file if it exists.
crypt.setOverwriteMode(AesCryptOwMode.on);

// If the file exists, stops the operation and throws 'AesCryptException'
// exception with 'AesCryptExceptionType.destFileExists' type (see 
// example1.dart in 'example'  folder). This mode is set by default.
crypt.setOverwriteMode(AesCryptOwMode.warn);

// If the file exists, adds index '(1)' to its' name and tries to save. 
// If such file also exists, adds '(2)' to its name, then '(3)', etc. 
crypt.setOverwriteMode(AesCryptOwMode.rename);

Notice: All functions having 'Sync' at the end of their names are synchronous. If you need asynchronous ones, please just remove 'Sync' from the end of function name.

File encryption/decryption:

// Encrypts the file srcfile.txt and saves encrypted file under original name 
// with '.aes' extention added (srcfile.txt.aes). You can specify relative or 
// direct path to it. To save the file into current directory specify it 
// either as './srcfile.txt' or as 'srcfile.txt'.
crypt.encryptFileSync('srcfile.txt');

// Encrypts the file srcfile.txt and saves encrypted file under 
// the name enc_file.txt.aes
crypt.encryptFileSync('srcfile.txt', 'enc_file.txt.aes');

// Decrypts the file srcfile.txt.aes and saves decrypted file under 
// the name srcfile.txt
crypt.decryptFileSync('srcfile.txt.aes');

// Decrypts the file srcfile.txt.aes and saves decrypted file under 
// the name dec_file.txt
crypt.decryptFileSync('srcfile.txt.aes', 'dec_file.txt');

Text <=> file encryption/decryption:

String decryptedText;

// Plain text to be encrypted
String srcText = 'some text';

// Encrypts the text as UTF8 string and saves it into 'mytext.txt.aes' file.
crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes');
// Encrypts the text as UTF16 Big Endian string and saves it 
// into 'mytext.txt.aes' file.
crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes', utf16: true);
// Encrypts the text as UTF16 Little Endian string and saves it 
// into 'mytext.txt.aes' file.
crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes', utf16: true, endian: Endian.little);
// Add 'bom: true' as an argument if you want to add byte order mark 
// at the beginning of the text string before the encryption. For example:
// crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes', bom: true);

// Decrypts the file and interprets it based on byte order mark if it has one.
// Otherwise it will be interpreted as UTF8 text.
decryptedString = crypt.decryptTextFromFileSync('mytext.txt.aes');
// Decrypts the file and interprets it based on byte order mark if it has one.
// Otherwise it will be interpreted as UTF16 Big Endian text.
decryptedString = crypt.decryptTextFromFileSync('mytext.txt.aes', utf16: true);
// Decrypts the file and interprets it based on byte order mark if it has one.
// Otherwise it will be interpreted as UTF16 Little Endian text.
decryptedString = crypt.decryptTextFromFileSync('mytext.txt.aes', utf16: true, endian: Endian.little);

Binary data <=> file encryption/decryption:

// Binary data to be encrypted
Uint8List srcData = Uint8List.fromList([1,2,3,4,5]);

// Encrypts the data and saves it into mydata.bin.aes file.
crypt.encryptDataToFileSync(srcData, 'mydata.bin.aes');

// Decrypt the data from 'mydata.bin.aes' file
Uint8List decryptedData = crypt.decryptDataFromFileSync('mydata.bin.aes');

Binary data AES encryption/decryption:

// The encryption key. It should be 128, 192 or 256 bits long.
Uint8List key = Uint8List.fromList([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);

// The initialization vector used in advanced cipher modes. 
// It must be 128 bits long.
Uint8List iv = Uint8List.fromList([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);

// AES mode of operation. It can be one of the next values:
//    AesMode.ecb - ECB (Electronic Code Book)
//    AesMode.cbc - CBC (Cipher Block Chaining)
//    AesMode.cfb - CFB (Cipher Feedback)
//    AesMode.ofb - OFB (Output Feedback)
// By default the mode is AesMode.cbc
AesMode mode = AesMode.cbc; // Ok. I know it's meaningless here.

// Sets the encryption key and IV.
crypt.aesSetKeys(key, iv);
// Sets cipher mode
crypt.aesSetMode(mode);

// If you wish you can set the key, IV and cipher mode in one function.
//crypt.aesSetParams(key, iv, mode);

// The binary data to be encrypted
Uint8List srcData = Uint8List.fromList([1,2,3,4,5]);

// Encrypts the data. Padding scheme - null byte (0x00).
Uint8List encryptedData = crypt.aesEncrypt(srcData);
// Decrypts the data
Uint8List decryptedData = crypt.aesDecrypt(encryptedData);

SHA256 and HMAC-SHA256 computation:

// The source data
Uint8List srcData = Uint8List.fromList([1,2,3,4,5,6,7,8,9]);

// Computes SHA256 hash
Uint8List hash = crypt.sha256(srcData);

// Secret cryptographic key for HMAC
Uint8List key = Uint8List.fromList([1,2,3]);

// Computes HMAC-SHA256 code
Uint8List hmac = crypt.hmacSha256(key, srcData);

Acknowledgments

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트