alexgoussev / aes_crypt Goto Github PK
View Code? Open in Web Editor NEWDart encryption library for encrypting/decrypting files, plain text and binary data in AES Crypt file format
License: MIT License
Dart encryption library for encrypting/decrypting files, plain text and binary data in AES Crypt file format
License: MIT License
I am using this library in flutter.
In
crypt.decryptDataFromFileSync(documentName)
documentName = assets/pdf/tfnt/tfnt_en.pdf
I am getting an error
FileSystemException: Source file assets/pdf/tfnt/tfnt_en.pdf does not exist., path = ''
Does the library support reading files in the assets directory?
As the title says, could you make the encryption/decryption process faster?
i have encryption file when i decrypt it i get the error
The chunk 'file header' was expected to be 414553 but found EEFBE5
what does this mean??
String decryptFile(String path) {
AesCrypt crypt = AesCrypt();
crypt.setOverwriteMode(AesCryptOwMode.on);
crypt.setPassword('my-password');
crypt.aesSetMode(AesMode.cbc);
String decFilepath;
try {
decFilepath = crypt.decryptFileSync(path);
} catch (e) {
print(e);
}
return decFilepath;
}
Do you have plans to update this splendid package to Sound Null Safety?
I have a Flutter v2.10.1 Windows desktop application that I'm trying to use aes_crypt in.
When I run the project, I get this compile error:
CUSTOMBUILD : error : Cannot run with sound null safety, because the following dependencies [[D:\Code\flutters\apps\cipher_text\build\windows\flutter\flutter_assemble.vcxproj]()]
[C:\Program]() Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066:
Custom build for '[D:\Code\flutters\apps\cipher_text\build\windows\CMakeFiles\28b7fc3e7c3090088060721c2e08b791\flutter_windows.dll.rule]();
[D:\Code\flutters\apps\cipher_text\build\windows\CMakeFiles\5ca9ed3df294d6b6de1a07c2fbdb5b3a\flutter_assemble.rule]()' exited with code 1.
[[D:\Code\flutters\apps\cipher_text\build\windows\flutter\flutter_assemble.vcxproj]()]
Exception: Build process failed.
>flutter doctor -v
[√] Flutter (Channel stable, 2.10.1, on Microsoft Windows [Version 10.0.19043.1526], locale en-US)
• Flutter version 2.10.1 at D:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision db747aa133 (12 days ago), 2022-02-09 13:57:35 -0600
• Engine revision ab46186b24
• Dart version 2.16.1
• DevTools version 2.9.2
Thank you for your time and consideration. Karl
When this package is going to be compatible for Dart 3 ?
Apologies for the question.
Can aes-crypt be used on Desktop Windows and macOS?
Thank you!
Karl
is this package supports flutter web?
if yes please share how to encrypt/decrypt text to file in flutter web.
when I try this:
var crypt = AesCrypt();
crypt.setPassword('my cool password');
String rs =
crypt.encryptTextToFileSync(plainText, 'mytext.txt.aes', utf16: true, );
print(rs);
it shows error as:
Error: Unsupported operation: Int64 accessor not supported by dart2js.
at Object.throw_ [as throw] (http://localhost:55860/dart_sdk.js:4334:11)
at DataView.[dartx.setInt64] (http://localhost:55860/dart_sdk.js:28815:17)
at http://localhost:55860/packages/aes_crypt/aes_crypt.dart.lib.js:1230:51
at aes_crypt._Cryptor.init.sha256 (http://localhost:55860/packages/aes_crypt/aes_crypt.dart.lib.js:1232:11)
at aes_crypt._Cryptor.init.[_keysJoin] (http://localhost:55860/packages/aes_crypt/aes_crypt.dart.lib.js:1452:20)
at aes_crypt._Cryptor.init.[_createDataParts] (http://localhost:55860/packages/aes_crypt/aes_crypt.dart.lib.js:1510:61)
at aes_crypt._Cryptor.init.encryptDataToFileSync (http://localhost:55860/packages/aes_crypt/aes_crypt.dart.lib.js:775:29)
at aes_crypt.AesCrypt.new.encryptDataToFileSync (http://localhost:55860/packages/aes_crypt/aes_crypt.dart.lib.js:418:92)
at aes_crypt.AesCrypt.new.encryptTextToFileSync (http://localhost:55860/packages/aes_crypt/aes_crypt.dart.lib.js:425:19)
at Backup.Backup.new.backupdata (http://localhost:55860/packages/website/Dynamic/CustBalDeepLink.dart.lib.js:80737:24)
at backupdata.next (<anonymous>)
at http://localhost:55860/dart_sdk.js:37603:33
at _RootZone.runUnary (http://localhost:55860/dart_sdk.js:37457:58)
at _FutureListener.thenAwait.handleValue (http://localhost:55860/dart_sdk.js:32441:29)
at handleValueCallback (http://localhost:55860/dart_sdk.js:32988:49)
at Function._propagateToListeners (http://localhost:55860/dart_sdk.js:33026:17)
at _Future.new.[_completeWithValue] (http://localhost:55860/dart_sdk.js:32869:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:55860/dart_sdk.js:32891:35)
at Object._microtaskLoop (http://localhost:55860/dart_sdk.js:37718:13)
at _startMicrotaskLoop (http://localhost:55860/dart_sdk.js:37724:13)
I'm new to this. please help me to encrypt & decrypt my String to file
read data from internet
hi,
CTR is one of the main major algorithms of AES encryption but there is no implementation for it in this library, why?
is it going to be included in the future?
Can aes-crypt be used on Flutter Web?
I'm using windows 10 pro and Android Studio 3.6.2
And the piece of Flutter code project where I'm testing aes_cryp is:
...
class _MyHomePageState extends State {
int _counter = 0;
String decText = '';
String encFilepath = '';
String srcText = 'Este é o texto que desejo encriptar;'
'Espero que o mesmo seja corretamente'
'encriptado e posteriormente decriptado';
void _incrementCounter() {
debugPrint('bpt1');
seatst();
setState(() {
//debugPrint('bpt2');
_counter++;
});
}
void seatst(){
debugPrint('bpt2');
debugPrint('Source string: $srcText\n');
var crypt = AesCrypt('bibliotecadepasswords são sempre necessarias');
encFilepath = crypt.encryptTextToFileSync(srcText, 'D:/ProjFlutter/flutter_aes256_app/test/seatestfile.txt.aes', utf16: true);
...
The following code isn't possible ...
crypt.aesSetMode(AesMode.ecb);
crypt.aesSetKeys(keyBytes, Uint8List(0));
The only way was copy the project and comment the line below:
void aesSetKeys(Uint8List key, [Uint8List iv]) {
if (![16, 24, 32].contains(key.length)) {
throw AesCryptArgumentError('Invalid key length for AES. Provided ${key.length * 8} bits, expected 128, 192 or 256 bits.');
} else if (_aesMode != AesMode.ecb && iv.isNullOrEmpty) {
throw AesCryptArgumentError('The initialization vector is not specified. It can not be empty when AES mode is not ECB.');
} else if (iv.length != 16) {
// throw AesCryptArgumentError('Invalid IV length for AES. The initialization vector must be 128 bits long.');
}
Error for example of binary data AES encryption/decryption:
Uint8List key = Uint8List.fromList(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
Uint8List iv = Uint8List.fromList(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
var crypt = AesCrypt('my cool password');
crypt.aesSetParams(key, iv, AesMode.cbc);
Uint8List srcData = Uint8List.fromList([1, 2, 3, 4, 5]);
Uint8List encryptedData = crypt.aesEncrypt(srcData); // error on this line
Uint8List decryptedData = crypt.aesDecrypt(encryptedData);
Invalid argument(s): Invalid data length for AES: 5 bytes. #0 _Aes.aesEncrypt (package:aes_crypt/src/aes.dart:244:7) #1 AesCrypt.aesEncrypt (package:aes_crypt/src/aescrypt.dart:370:48) #2 main (package:aestest/aes.dart:36:35) #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19) #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
According to node.js Documentation encoding : null when binary data to be sent via Api,
https://www.npmjs.com/package/request in this link below mentioned explanation is found.
encoding - encoding to be used on setEncoding of response data. If null, the body is returned as a Buffer. Anything else (including the default value of undefined) will be passed as the encoding parameter to toString() (meaning this is effectively utf8 by default).
Note: if you expect binary data, you should set encoding: null.
Now I have achieve the same thing in flutter/dart and this encoding parameter is not accepting null as here in node.js they have mentioned.
I want to know how to make this same Post request from Flutter/dart or at least android/java.
var enc = AESCrypt.encrypt(key, iv, JSON.stringify(obj_j));
var output = new Buffer.from(enc, 'hex'); // Buffer
function test() {
console.time("XXX");
request.post({
headers: {
'content-type': 'application/json'
}, //required, or webserver will ignore it application/json multipart/form-data
url: 'http://192.168.29.210/deviceid/read', // webserver url
encoding:null,
body: output
},
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.timeEnd("XXX");
body = AESCrypt.decrypt(key, iv, body);
//body is decrypted http response, can be parsed with json method
fs.writeFile('input.json', body, function (err) {
if (err) {
return console.error(err);
}
});
}
});
};
Adding code the What i have tried in flutter
var headers = {'Content-Type': 'application/json'};
var request =
http.Request('POST', Uri.parse('http://192.168.29.210/deviceid/read'));
request.body = encryptedText;
request.encoding = null ; // here this null parameter is not acceptable
request.encoding = Encoding.getByName("utf-8")); // only this option is available to add in flutter
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
Even in post man this encoding variable is not present to set it.
how to send the binary data that is Uint8List to the POST api body,
which is working with node.js code shown above with 200 ok response. but in flutter the same api returning 408
This package is very useful for my project, but its already outdated for 2023 flutter/dart version, if you update it to support null safety it would be very helpful for us, Thank you :D
aes_crypt no padding,could you add ?
If anyone needs null safe version of this package I have created one.
https://pub.dev/packages/aes_crypt_null_safe
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.