# flutter_string_encryption
Cross-platform string encryption using common best-practices
(AES/CBC/PKCS5/Random IVs/HMAC-SHA256 Integrity Check).
It uses the format described in [this article](https://tozny.com/blog/encrypting-strings-in-android-lets-make-better-mistakes/).
It currently uses Native Platform implementations, which are (we all hope)
constantly vetted and updated by Apple and Google, with some really tiny
library wrappers to ease some of the tedious work.
For the Android side, I used the following library (coming from the same
authors of the article above):
https://github.com/tozny/java-aes-crypto
For the iOS side, I implemented the format described in the article
directly inside the native plugin, and used the following library to
help me with Apple's CommonCrypto functions which are not really easy to
interact with otherwise:
https://github.com/sgl0v/SCrypto
## Support
In order to work on iOS, you need to bump the iOS support version up to
9.0. This can be done inside your ios project Podfile by uncommenting
the very first line of the file:
```
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
```
## Usage
```dart
final cryptor = new PlatformStringCryptor();
```
## Generate A Secret Key
### Randomly
Generate it and store it in a safe place - e.g. the Keychain/KeyStore
```dart
final String key = await cryptor.generateRandomKey();
```
### Password-Based
Generate and (safely) store the salt, and then generate the key with a user-provided
password before encrypting/decrypting your strings.
```dart
final password = "user_provided_password";
final String salt = await cryptor.generateSalt();
final String key = await cryptor.generateKeyFromPassword(password, salt);
```
## Encrypt A String
```dart
final String encrypted = await cryptor.encrypt("A string to encrypt.", key);
```
## Decrypt A String
```dart
try {
final String decrypted = await cryptor.decrypt(encrypted, key);
print(decrypted); // - A string to encrypt.
} on MacMismatchException {
// unable to decrypt (wrong key or forged data)
}
```
# License
MIT (both this plugin and the used helper libraries).
没有合适的资源?快使用搜索试试~ 我知道了~
使用通用最佳实践的跨平台字符串加密。.zip
共84个文件
png:22个
gitignore:6个
iml:5个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 201 浏览量
2023-03-26
23:56:46
上传
评论
收藏 187KB ZIP 举报
温馨提示
使用通用最佳实践的跨平台字符串加密。.zip
资源推荐
资源详情
资源评论
收起资源包目录
使用通用最佳实践(AESCBCPKCS5RandomIVsHMAC-SHA256IntegrityCheck)的跨平台字符串加密。.zip (84个子文件)
flutter_string_encryption-master
lib
flutter_string_encryption.dart 3KB
flutter_string_encryption.iml 747B
LICENSE 3KB
android
gradle.properties 29B
gradle
wrapper
gradle-wrapper.jar 52KB
src
main
kotlin
com
github
sroddy
flutterstringencryption
FlutterStringEncryptionPlugin.kt 2KB
AndroidManifest.xml 136B
gradlew.bat 2KB
build.gradle 1KB
settings.gradle 47B
gradlew 5KB
.gitignore 97B
CHANGELOG.md 282B
flutter_string_encryption_android.iml 2KB
ios
flutter_string_encryption.podspec 799B
Assets
.gitkeep 0B
Classes
SwiftFlutterStringEncryptionPlugin.swift 6KB
FlutterStringEncryptionPlugin.h 101B
FlutterStringEncryptionPlugin.m 315B
.gitignore 263B
.gitignore 84B
example
lib
main.dart 2KB
flutter_string_encryption_example_android.iml 1KB
android.iml 580B
android
gradle.properties 29B
gradle
wrapper
gradle-wrapper.jar 52KB
gradle-wrapper.properties 231B
app
src
main
res
mipmap-xxhdpi
ic_launcher.png 1KB
mipmap-hdpi
ic_launcher.png 544B
mipmap-mdpi
ic_launcher.png 442B
mipmap-xxxhdpi
ic_launcher.png 1KB
mipmap-xhdpi
ic_launcher.png 721B
values
styles.xml 361B
drawable
launch_background.xml 434B
kotlin
com
github
sroddy
flutterstringencryptionexample
MainActivity.kt 366B
AndroidManifest.xml 2KB
build.gradle 2KB
gradlew.bat 2KB
build.gradle 582B
settings.gradle 480B
gradlew 5KB
.gitignore 136B
.metadata 286B
flutter_string_encryption_example.iml 824B
ios
Runner.xcworkspace
contents.xcworkspacedata 224B
Podfile 2KB
Flutter
AppFrameworkInfo.plist 863B
Debug.xcconfig 106B
Release.xcconfig 108B
Runner
Base.lproj
Main.storyboard 2KB
LaunchScreen.storyboard 2KB
Runner-Bridging-Header.h 37B
AppDelegate.swift 403B
Info.plist 2KB
Assets.xcassets
LaunchImage.imageset
AppIcon.appiconset
Contents.json 2KB
[email protected] 564B
Runner.xcodeproj
xcshareddata
xcschemes
Runner.xcscheme 3KB
project.pbxproj 22KB
project.xcworkspace
contents.xcworkspacedata 152B
.gitignore 488B
Podfile.lock 803B
.gitignore 110B
README.md 212B
pubspec.yaml 2KB
README.md 2KB
pubspec.yaml 617B
共 84 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功