leocavalcante / encrypt Goto Github PK
View Code? Open in Web Editor NEWπ A set of high-level APIs over PointyCastle for two-way cryptography.
License: BSD 3-Clause "New" or "Revised" License
π A set of high-level APIs over PointyCastle for two-way cryptography.
License: BSD 3-Clause "New" or "Revised" License
Hi there!
I'm having an issue when I try to pass padding: null
to the AES encrypter. I'm getting exception: flutter: Another exception was thrown: RangeError (index): Index out of range: index should be less than 36: 36
All I'm doing (so far) is instantiating a Crypto object and calling encrypt
on a string. Here's my Crypto class:
import 'dart:typed_data';
import 'package:encrypt/encrypt.dart';
import 'package:password_hash/pbkdf2.dart';
class Crypto {
final String salt;
final String encryptionKey;
String key_256;
Encrypter encrypter;
Crypto({this.salt, this.encryptionKey}) {
var generator = new PBKDF2();
key_256 = generator.generateBase64Key(encryptionKey, salt, 1, 32);
encrypter = Encrypter(
AES(Key.fromBase64(key_256), mode: AESMode.ctr, padding: null),
);
}
Encrypted encrypt(String text) {
Uint8List list =
Uint8List.fromList([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]);
IV iv = IV(list);
Encrypted encrypted = encrypter.encrypt(text, iv: iv);
return encrypted;
}
String decrypt(Encrypted encrypted) {
Uint8List list =
Uint8List.fromList([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]);
IV iv = IV(list);
String decrypted = encrypter.decrypt(encrypted, iv: iv);
return decrypted;
}
}
And here's the full debug console:
flutter: βββ‘ EXCEPTION CAUGHT BY WIDGETS LIBRARY ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
flutter: The following IndexError was thrown building RandomScreen(dirty, dependencies:
flutter: [InheritedProvider<User>, InheritedProvider<FirebaseUser>]):
flutter: RangeError (index): Index out of range: index should be less than 36: 36
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2188:7)
flutter: #1 SICStreamCipher.processBytes
package:pointycastle/stream/sic.dart:61
flutter: #2 StreamCipherAsBlockCipher.processBlock
package:pointycastle/adapters/stream_cipher_as_block_cipher.dart:31
flutter: #3 AES._processBlocks
package:encrypt/β¦/algorithms/aes.dart:45
flutter: #4 AES.encrypt
package:encrypt/β¦/algorithms/aes.dart:22
flutter: #5 Encrypter.encryptBytes
package:encrypt/src/encrypter.dart:11
flutter: #6 Encrypter.encrypt
package:encrypt/src/encrypter.dart:16
flutter: #7 Crypto.encrypt
package:frankly_native/services/crypto.dart:23
flutter: #8 RandomScreen.build
package:frankly_native/screens/random.dart:19
flutter: #9 StatelessElement.build
package:flutter/β¦/widgets/framework.dart:3789
flutter: #10 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3739
flutter: #11 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #12 StatelessElement.update
package:flutter/β¦/widgets/framework.dart:3796
flutter: #13 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #14 SingleChildRenderObjectElement.update
package:flutter/β¦/widgets/framework.dart:4883
flutter: #15 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #16 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #17 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #18 StatelessElement.update
package:flutter/β¦/widgets/framework.dart:3796
flutter: #19 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #20 SingleChildRenderObjectElement.update
package:flutter/β¦/widgets/framework.dart:4883
flutter: #21 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #22 SingleChildRenderObjectElement.update
package:flutter/β¦/widgets/framework.dart:4883
flutter: #23 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #24 RenderObjectElement.updateChildren
package:flutter/β¦/widgets/framework.dart:4601
flutter: #25 MultiChildRenderObjectElement.update
package:flutter/β¦/widgets/framework.dart:4992
flutter: #26 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #27 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #28 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #29 StatefulElement.update
package:flutter/β¦/widgets/framework.dart:3894
flutter: #30 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #31 SingleChildRenderObjectElement.update
package:flutter/β¦/widgets/framework.dart:4883
flutter: #32 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #33 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #34 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #35 StatefulElement.update
package:flutter/β¦/widgets/framework.dart:3894
flutter: #36 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #37 SingleChildRenderObjectElement.update
package:flutter/β¦/widgets/framework.dart:4883
flutter: #38 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #39 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #40 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #41 StatefulElement.update
package:flutter/β¦/widgets/framework.dart:3894
flutter: #42 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #43 SingleChildRenderObjectElement.update
package:flutter/β¦/widgets/framework.dart:4883
flutter: #44 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #45 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #46 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #47 StatefulElement.update
package:flutter/β¦/widgets/framework.dart:3894
flutter: #48 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #49 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #50 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #51 StatelessElement.update
package:flutter/β¦/widgets/framework.dart:3796
flutter: #52 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #53 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #54 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #55 StatefulElement.update
package:flutter/β¦/widgets/framework.dart:3894
flutter: #56 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #57 SingleChildRenderObjectElement.update
package:flutter/β¦/widgets/framework.dart:4883
flutter: #58 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #59 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #60 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #61 ProxyElement.update
package:flutter/β¦/widgets/framework.dart:4006
flutter: #62 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #63 SingleChildRenderObjectElement.update
package:flutter/β¦/widgets/framework.dart:4883
flutter: #64 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #65 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #66 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #67 StatefulElement.update
package:flutter/β¦/widgets/framework.dart:3894
flutter: #68 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #69 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #70 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #71 StatelessElement.update
package:flutter/β¦/widgets/framework.dart:3796
flutter: #72 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #73 SingleChildRenderObjectElement.update
package:flutter/β¦/widgets/framework.dart:4883
flutter: #74 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #75 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #76 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #77 ProxyElement.update
package:flutter/β¦/widgets/framework.dart:4006
flutter: #78 Element.updateChild
package:flutter/β¦/widgets/framework.dart:2753
flutter: #79 ComponentElement.performRebuild
package:flutter/β¦/widgets/framework.dart:3750
flutter: #80 Element.rebuild
package:flutter/β¦/widgets/framework.dart:3565
flutter: #81 BuildOwner.buildScope
package:flutter/β¦/widgets/framework.dart:2278
flutter: #82 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame
package:flutter/β¦/widgets/binding.dart:700
flutter: #83 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback
package:flutter/β¦/rendering/binding.dart:286
flutter: #84 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback
package:flutter/β¦/scheduler/binding.dart:1012
flutter: #85 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame
package:flutter/β¦/scheduler/binding.dart:952
flutter: #86 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure>
package:flutter/β¦/scheduler/binding.dart:773
flutter: #88 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
flutter: #89 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
flutter: #90 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)
flutter: (elided one frame from package dart:async-patch)
flutter: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Reloaded 11 of 684 libraries in 386ms.
flutter: Another exception was thrown: RangeError (index): Index out of range: index should be less than 36: 36
I don't get this error when I remove padding: null
from the Encrypter. But, I'm already encrypting using AES.ctr in my web app (using the aesjs library), which doesn't add padding.
Can you point me in the right direction?
Thanks for your help!
I tried to encrypt a string in dart with Encrypt, but, when i compared it with that openssl on php gave me, it didn't match. I tried every padding avaible.
Is there any plan to add ChaCha20? Thanks.
How I can to use a key of the length 64?
For example:
var myKey = HMAC256('my awesome message', 'my secret key 123') // 1a991c1e2984f20af91361f916a708b1fc7e247f8f4e6cc090b89fe0280d39ed
final key = Key.fromUtf8(myKey);
First I use my key (Len:50) and I get below error. Error state that key must be 128/192 or 256bits.
I am confuse here. You have 32 character and its works.
https://stackoverflow.com/questions/4850241/how-many-bits-in-a-character has a explain that it depends what is the character and what encoding it is in. So do you going to support ISO-8895-1 tp ISO-8895-9 as well as, UTF-8, UTF-16, UTF-32 encoding type?
I will stick to 32 length now. My local language is TR and ISO-8895-5 (Latin-5 (Turkish)). It will be good to cover all other language. Thanks
Unhandled exception:
Invalid argument(s): Key length must be 128/192/256 bits
#0 AESFastEngine.init (package:pointycastle/block/aes_fast.dart:66:7)
#1 AES.encrypt (package:encrypt/src/aes.dart:20:9)
#2 Encrypter.encrypt (package:encrypt/encrypt.dart:17:17)
#3 main (file:///Users/niyazitoros/IdeaProjects/github/untitled/bin/main.dart:11:35)
#4 _startIsolate. (dart:isolate-patch/dart:isolate/isolate_patch.dart:279)
#5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:165)
How can i get the data:
static Future post(String url, List<int> data) async {
Response rsp = await dio.post(url, data: data, options: Options(responseType: ResponseType.bytes));
return rsp.data;
}
How to use this lib:
static List<int> aes128Decode(List<int> data) {
final key = Key.fromUtf8('xxxxxxxxxxxxxxxx');
final iv = IV.fromLength(16);
final encrypter = Encrypter(AES(key, iv, mode: AESMode.ecb));
print(data);
final encrypted = Encrypted(Uint8List.fromList(data));
return encrypter.decrypt(encrypted).runes.toList();
}
The data like this: (console print)
[90, 94, 169, 122, 182, 145, 29, 101, 77, 245, 27, 223, 120, 103, 10, 194, 46, 197, 31, 0, 105, 197, 5, 94, 153, 24, 105, 142, 147, 46, 51, 224, 86, 113, 199, 20, 84, 61, 171, 72, 132, 189, 253, 90, 228, 134, 201, 232, 244, 150, 190, 63, 226, 81, 12, 75, 140, 55, 73, 162, 142, 171, 248, 36, 199, 241, 183, 236, 109, 145, 37, 172, 63, 219, 53, 197, 255, 165, 204, 167, 110, 4, 55, 187, 189, 202, 219, 100, 66, 48, 91, 231, 248, 46, 121, 66, 85, 21, 188, 33, 168, 254, 129, 253, 42, 129, 230, 85, 19, 14, 11, 118, 225, 30, 169, 178, 86, 251, 139, 177, 63, 85, 92, 195, 223, 45, 70, 148, 245, 88, 228, 247, 62, 46, 187, 161, 171, 102, 192, 101, 76, 116, 23, 91, 58, 238, 119, 108, 15, 135, 49, 8, 203, 126, 188, 181, 27, 184, 77, 119, 62, 167, 89, 176, 73, 226, 227, 195, 8, 220, 164, 73, 50, 253, 9, 120, 56, 143, 50, 2, 169, 198, 113, 136, 232, 64, 83, 87, 19, 164, 235, 179, 196, 163, 40, 98, 186, 179, 10, 94, ......
I got this error:
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: Invalid argument(s): Invalid or corrupted pad block
#0 PKCS7Padding.padCount
package:pointycastle/paddings/pkcs7.dart:40
#1 PaddedBlockCipherImpl.doFinal
package:pointycastle/padded_block_cipher/padded_block_cipher_impl.dart:106
#2 PaddedBlockCipherImpl.process
package:pointycastle/padded_block_cipher/padded_block_cipher_impl.dart:69
#3 AES.decrypt
../β¦/algorithms/aes.dart:36
#4 Encrypter.decrypt
../β¦/src/encrypter.dart:16
#5 DataCodec.aes128Decode
/β¦/api/data_codec.dart:29
#6 Request.start.<anonymous closure>
/β¦/api/request.dart:111
#7 _rootRunUnary (dart:async/zone.dart:1132:38)
#8 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#9 _FutureListener.handleValu<β¦>
Can you help me? i am not good at encrypt.
I just know the data is encoded by aes128.
Does the data need some additional processed?
Hi, I want to know how to use AES/ECB/NoPadding in Dart. Does encrypt support it? Thank you.
What type payment do you accept other than PayPal?
I am from Turkey and PayPal doesn't accept card from my country?
My server workmate decide use RSA and AES to encode and decode data,The AES rule is AES/CBC/PKCS5Padding,but the defualt padding is PKCS7,there is no choice for PKCS5,how could I use for PKCS5Padding?
Hi,
we're using AES with ECB to encrypt/decrypt binary data (chunks of 16 bytes) sourcing from a BLE device. This is the decrypt part:
String buf = hex.encode(chunk);
String decodedDataStr = _aesDecrypter.decrypt16(buf);
Uint8List decodedData = Uint8List.fromList(decodedDataStr.codeUnits);
With the current implementation, using βdecrypt16β and then the βString.codeUnitsβ property to get Uint8List, it seems that some sequences like:
[0xFF, 0xFF, 0xFF, 0xFF, ...up to 16 bytes.... ] (values before encryption)
decodes the β0xFFβ values as β0xFDβ, obviously causing big problems.
Could you please implements decryptBytes(List) -> List as you did for encryptBytes?
Thanks a lot
Francesco
Hi,
I am trying to use your Salsa20 encrypt plugin in my flutter app to make encrypted string and send to server via https.
I found it is much faster than what I am using now. And also your Salsa20 supports ISO 8859-9 character.
First question is how secure is Salsa20 for my Flutter app?
Second question I implement your example and find different output. Why is that?
More Info: (bear with me)
copy paste your salsa20 example and output is:
1viEPvZsG2vlfwoBIZPEu5EOFJBlPsgUq+hkBuMFgJVYirS/X6KLPt3WCuuQ+qVMdU6fXb/z7w==
Lorem ipsum dolor sit amet, consectetur adipiscing elit
My fuller app sends query to server and server returns a result. In middle I am using aqueduct server so I can re format bot communication and resolve the encryption.
My server uses cp437 ib code page and in aqueduct I replace the bytes from Flutter to IBM CP437 code page and also I replace the bytes from aqueduct CP437 to Flutter.
My server doesn't use special character in ISO 8859-9. It uses similar to CP437 code page.
So last question is base on the different output you and me how can I use Salsa20 in my flutter app and the aqueduct server so they can communicate securely?
Last:
How can I use Salse20 to get from this:
1viEPvZsG2vlfwoBIZPEu5EOFJBlPsgUq+hkBuMFgJVYirS/X6KLPt3WCuuQ+qVMdU6fXb/z7w==
to this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit
Thanks
We are planning to use AES encryption on the mobile application and server side.
Server side using Microsoft AES libraries (https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.aes?view=netframework-4.7.2) but required to pass key and IV to encrypt text.
but, IV is not supported in your libraries. Do you have any plans to enhance the libraries to include IV and match with standard encryption libraries?
Thanks
Thank you for this package.
I want to use in our project. When I decrypt small string, there is no problem.
But we encrypt large pdf file with aes. When we try decrypt file from base64 string, there is no action. No error or else.
How can i decrypt large file (30mb, 90mb, ...) with aes?
String decrypt(Encrypted encrypted) {
final key =
encyrpt.Key.fromBase64("JTSBh84u1w2HScX3B7ndj3RwzDNbF.....");
final iv = IV.fromBase64("h0nF9we53Y95op.....");
final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
try {
final decrypted = encrypter.decrypt(encrypted, iv: iv);
return decrypted;
} catch (e) {
print(e);
}
}
The RSAKeyParser fails to parse a key that contains CRLF line endings. There is even a comment in the parse method.
/// RSA PEM parser.
class RSAKeyParser {
/// Parses the PEM key no matter it is public or private, it will figure it out.
RSAAsymmetricKey parse(String key) {
final rows = key.split('\n'); // LF-only, this could be a problem
final header = rows.first;
when I add encrypt: ^3.1.0 in my project,and then import'package:encrypt/encrypt.dart' in where should be used ,but it pointed out the URI didn't exist,so what should i do?
input characters limited to 16,32,64 and so on otherwise it returns Input buffer too short.
`String _publicKey = '-----BEGIN PUBLIC KEY-----xxxxxxxxxxx-----END PUBLIC KEY-----';
Future rsaEncryptString(String source) async{
final parser = RSAKeyParser();
final RSAPublicKey publicKey = parser.parse(_publicKey);
final encrypter = Encrypter(RSA(publicKey: publicKey));
final encrypted = encrypter.encrypt('sssss');
print(encrypted);
}`
whats wrong with my code?
Hi,
I'm new in flutter and using PHP OpenSSL encrypt with AES-256-CBC mode.
I want to decrypt output in a flutter, but get an error message:
"Invalid argument(s): Input buffer too short".
I saw #53 and #8 but cannot solve my problem.
Also, try to decrypt on the web and get success.
https://encode-decode.com/aes-256-cbc-encrypt-online/
txt = k2EfYozdaJudTbKjPj2WmQ==
eKey = &5P483usHDhA32JUj55@CdcrbupasysB
This is my code in Flutter:
void decrypt(String txt, String eKey) {
final key = Enq.Key.fromUtf8(eKey);
final iv = Enq.IV.fromLength(16);
var ttt = utf8.decode(base64Decode(txt));
final encrypter = Enq.Encrypter(Enq.AES(key, mode: Enq.AESMode.cbc));
final input = Enq.Encrypted.fromUtf8(ttt);
final decrypted = encrypter.decrypt(input, iv: iv);
print(decrypted);
}
Thanks for the help. @leocavalcante
Hi @leocavalcante, I want to know if it is (or if it will be) possible to encrypt/decrypt using AES and the Galois/Counter Mode (GCM) with your library.
Thanks by advance π
I think it messes up some special characters such as 'Ε'.
Here is some of my code:
get encrypter async => new Encrypter(new AES(await key));
Future<String> doEncrypt(String text) async {
Encrypted encrypted = (await encrypter).encrypt(text);
return encrypted.base64;
}
Future<String> doDecrypt(String text) async {
try {
Encrypted encrypted = Encrypted(base64.decode(text));
return (await encrypter).decrypt(encrypted).toString();
} catch (e) {
return "";
}
}
Or here is a full example with the demo code:
import 'package:encrypt/encrypt.dart';
void main() {
final key = 'my 32 length key................';
final encrypter = Encrypter(AES(key));
final plainText = 'ΕΕΕΕΕ Γpsum dolor sit amet, consectetur adipiscing elit';
final encrypted = encrypter.encrypt(plainText);
final decrypted = encrypter.decrypt(encrypted);
print(decrypted);
}
How to encrypt this : "Text to encrypt π" . UInt8List ? plugin works well (RSA private/public key and Salsa20)
mode: AESMode.ecb
type 'ParametersWithIV' is not a subtype of type 'KeyParameter' of 'params'
Other results are different from this website http://tool.chacuo.net/cryptaes . My background data is consistent with this website.
How can I encrypt a string message with only public key or modulus and exponent?
Refer to this - dart-lang/sdk#36760
[abstract class Key, class Key extends Encrypted]
The name 'Key' is defined in the libraries 'package:encrypt/encrypt.dart' and 'package:flutter/src/foundation/key.dart'.dart(ambiguous_import)
Good morrning Leo Cavalcante, this is awesome news for us. I will try it today and donate. Thank you very much. At last we can make 2 way encrypted communication between Flutter and aqueduct... 5 am in my country now. I will test this when I go to work. Kind Regards...
static List<int> aes128Decode(List<int> data) {
final key = Key.fromUtf8('15helloTCJTALK20');
final iv = IV.fromLength(16);
final encrypter = Encrypter(AES(key, iv, mode: AESMode.ecb, padding: null));
final encrypted = Encrypted(Uint8List.fromList(data));
print("original: $data");
print("Uint8List: ${Uint8List.fromList(data)}");
final result = encrypter.decrypt(encrypted);
print('result: ${result}');
return result.runes.toList();
}
flutter: original: [17, 224, 52, 85, 164, 137, 148, 236, 196, 53, 80, 125, 53, 13, 44, 30, 54, 190, 172, 57, 111, 245, 100, 145, 153, 69, 59, 32, 229, 59, 61, 18, 247, 169, 7, 188, 32, 186, 28, 224, 124, 71, 191, 191, 198, 79, 102, 226, 228, 94, 168, 232, 186, 75, 58, 179, 254, 22, 52, 59, 190, 242, 84, 213, 254, 110, 174, 191, 8, 229, 54, 99, 99, 156, 146, 249, 144, 238, 195, 250, 211, 209, 206, 248, 151, 35, 4, 199, 72, 163, 193, 187, 170, 133, 151, 172, 106, 226, 69, 145, 235, 20, 231, 51, 128, 35, 25, 36, 207, 178, 148, 49, 207, 44, 218, 100, 233, 120, 108, 131, 21, 166, 249, 151, 101, 233, 73, 162, 131, 107, 66, 125, 212, 22, 35, 247, 182, 222, 15, 169, 109, 67, 111, 242, 136, 189, 193, 199, 44, 200, 35, 180, 62, 71, 60, 73, 226, 59, 164, 119, 60, 231, 127, 236, 85, 98, 241, 58, 219, 30, 242, 104, 125, 4, 225, 218, 248, 215, 134, 142, 251, 242, 201, 192, 245, 21, 253, 180, 70, 243, 49, 179, 171, 73, 133, 4, 171, 187, 186, 167, 51, 194, 73, 91, 50, 141, 120, 174, 76, 74, 129, 83, 229, 246, <β¦>
flutter: Uint8List: [17, 224, 52, 85, 164, 137, 148, 236, 196, 53, 80, 125, 53, 13, 44, 30, 54, 190, 172, 57, 111, 245, 100, 145, 153, 69, 59, 32, 229, 59, 61, 18, 247, 169, 7, 188, 32, 186, 28, 224, 124, 71, 191, 191, 198, 79, 102, 226, 228, 94, 168, 232, 186, 75, 58, 179, 254, 22, 52, 59, 190, 242, 84, 213, 254, 110, 174, 191, 8, 229, 54, 99, 99, 156, 146, 249, 144, 238, 195, 250, 211, 209, 206, 248, 151, 35, 4, 199, 72, 163, 193, 187, 170, 133, 151, 172, 106, 226, 69, 145, 235, 20, 231, 51, 128, 35, 25, 36, 207, 178, 148, 49, 207, 44, 218, 100, 233, 120, 108, 131, 21, 166, 249, 151, 101, 233, 73, 162, 131, 107, 66, 125, 212, 22, 35, 247, 182, 222, 15, 169, 109, 67, 111, 242, 136, 189, 193, 199, 44, 200, 35, 180, 62, 71, 60, 73, 226, 59, 164, 119, 60, 231, 127, 236, 85, 98, 241, 58, 219, 30, 242, 104, 125, 4, 225, 218, 248, 215, 134, 142, 251, 242, 201, 192, 245, 21, 253, 180, 70, 243, 49, 179, 171, 73, 133, 4, 171, 187, 186, 167, 51, 194, 73, 91, 50, 141, 120, 174, 76, 74, 129, 83, 229, 246,<β¦>
flutter: result: {"moment":{"url"
The result just 16 characters. Should be a json string.
what's wrong?
Hi Leo,
I create a 2048 key. I crate dart console app. I keep getting this error. Any idea?
Error:
Unhandled exception:
FileSystemException: Cannot open file, path = 'public_key.pem' (OS Error: No such file or directory, errno = 2)
#0 _File.throwIfError (dart:io/file_impl.dart:643:7)
#1 _File.openSync (dart:io/file_impl.dart:487:5)
#2 _File.readAsBytesSync (dart:io/file_impl.dart:547:18)
#3 _File.readAsStringSync (dart:io/file_impl.dart:592:18)
My Code
class NtmsRsa {
getPrivateKey() {
final privateKeyFile = File('private_key.pem');
final parser = RSAKeyParser();
final privateKey = parser.parse(privateKeyFile.readAsStringSync()) as RSAPrivateKey;
return privateKey;
}
getPublicKey() {
final publicKeyFile = File('public_key.pem');
final parser = RSAKeyParser();
final publicKey = parser.parse(publicKeyFile.readAsStringSync()) as RSAPublicKey;
return publicKey;
}
}
I call as:
setPrivate.dart
Future<String> setPrivate(String capitalPrivateValue) async {
NtmsRsa _ntmsRsa = new NtmsRsa();
final encrypter = Encrypter(RSA(publicKey: _ntmsRsa.getPublicKey(), privateKey: _ntmsRsa.getPrivateKey()));
final encrypted = encrypter.encrypt(capitalPrivateValue);
return encrypted.base64;
}
main.dart
String _encryptedData = await setPrivate("$myString");
print(_encryptedData);
Is there any plan to add binary encode/decode methods to the interface?
To my understanding, it is insecure to use the same key, iv combination for encrypting multiple messages, at least in many contexts. The current Encrypter API seems to me like it encourages creating a single encrypter object (which has a static key,iv pair) and reusing it for encrypting multiple messages, which would then be insecure.
Am I misunderstanding how this works? If not, it might be good to warn about this pitfall, or change the API.
hi, i use this code to set the plaintText value, this is get from a variable called: content.
1 final key = 'my32lengthsupersecretnooneknows1';
2 final encrypter = new Encrypter(new AES(key));
3 final plainText = content.toString();
4 print('plainText: '+plainText);
5 final encryptedText = encrypter.encrypt(plainText);
6 print('encrypt: '+encryptedText);
but i get this error:
I/flutter (30752): plainText: new text
I/flutter (30752): βββ‘ EXCEPTION CAUGHT BY GESTURE ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
I/flutter (30752): The following ArgumentError was thrown while handling a gesture:
I/flutter (30752): Invalid argument(s): Input buffer too short
the sample only work if plain text is:
plainText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit ........';
if you change any word in the sample or add something more this fail
I/flutter ( 4277): plainText: Lorem ipsum dolor sit consectetur adipiscing elit .........
I/flutter ( 4277): βββ‘ EXCEPTION CAUGHT BY GESTURE ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
I/flutter ( 4277): The following ArgumentError was thrown while handling a gesture:
I/flutter ( 4277): Invalid argument(s): Input buffer too short
I/flutter ( 4277):
I/flutter ( 4277): When the exception was thrown, this was the stack:
I/flutter ( 4277): #0 AESFastEngine.processBlock (package:pointycastle/block/aes_fast.dart:113:7)
I/flutter ( 4277): #1 AES._processBlocks (package:encrypt/src/aes.dart:42:25)
I/flutter ( 4277): #2 AES.encrypt (package:encrypt/src/aes.dart:22:20)
I/flutter ( 4277): #3 Encrypter.encrypt (package:encrypt/encrypt.dart:17:17)
Can encrypt be decrypted only with a public encryption private key? I now want to implement such a function, put a private key on the server, the client puts a public key, the client uses the public key to encrypt the data, the server uses the private key to decrypt the data, and then the server encrypts the response data using the private key and sends it to the client. End, the client uses the public key to decrypt, this function I have implemented in C#, nodejs, golang, no method found on dart
Hi,
I'm trying to encode some binary data I receive as a List.
As the encrypt methods only receives String I need to create one using String.fromCharCodes (or UTF8Decoder), but with some specific sequences, this String constructor fails with "Bad UTF-8 encoding 0xf9".
I know you plan to release versions of 'encrypt' and 'decrypt' methods for binary data (issue #14); I would really need it for a project I'm working on; I have a (little) budget for this feature if you can deliver it fast (really fast...).
The data sequence I cannot encrypt is:
[17, 97, 97, 97, 0, 0, 0, 0, 0, 0, 0, 49, 50, 51, 52, 53, 0, 0, 0, 249, 24, 25, 5, 19, 12, 9, 0, 0, 0, 0, 0]
Thank you
Francesco
The encryptBytes method looks like this:
Encrypted encryptBytes(List<int> input, {IV iv}) {
return algo.encrypt(Uint8List.fromList(input), iv: iv);
}
If I supply a Uint8List
, it will be duplicated for no reason.
I would change the method to something like this:
Encrypted encryptBytes(List<int> input, {IV iv}) {
Uint8List bytes;
if (input is Uint8List) {
bytes = input;
} else {
bytes = Uint8List.fromList(input);
}
return algo.encrypt(bytes, iv: iv);
}
My app use aes decrypt64 occur crash.
This is my source code.
final encrypter =
Encrypter(AES(Constants.key, Constants.iv, mode: AESMode.cbc));
var encryptPassword = prefs.getString(Constants.PREF_PASSWORD) ?? "";
if (encryptPassword != "")
password = encrypter.decrypt64(encryptPassword);
and crash log
Non-fatal Exception: package:pointycastle/padded_block_cipher/padded_block_cipher_impl.dart 55 in PaddedBlockCipherImpl.process
0 ??? 0x0 PaddedBlockCipherImpl.process (padded_block_cipher_impl.dart:55)
1 ??? 0x0 AES.decrypt (aes.dart:36)
2 ??? 0x0 Encrypter.decrypt (encrypter.dart:16)
3 ??? 0x0 Encrypter.decrypt64 (encrypter.dart:26)
4 ??? 0x0 LoginPageState._getPreference (login_page.dart:292)
5 ??? 0x0 LoginPageState.initState (login_page.dart:41)
6 ??? 0x0 StatefulElement._firstBuild (framework.dart:3846)
7 ??? 0x0 ComponentElement.mount (framework.dart:3711)
8 ??? 0x0 Element.inflateWidget (framework.dart:2956)
9 ??? 0x0 Element.updateChild (framework.dart:2759)
10 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
11 ??? 0x0 Element.inflateWidget (framework.dart:2956)
12 ??? 0x0 Element.updateChild (framework.dart:2759)
13 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
14 ??? 0x0 Element.rebuild (framework.dart:3559)
15 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
16 ??? 0x0 ComponentElement.mount (framework.dart:3711)
17 ??? 0x0 Element.inflateWidget (framework.dart:2956)
18 ??? 0x0 Element.updateChild (framework.dart:2759)
19 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
20 ??? 0x0 Element.inflateWidget (framework.dart:2956)
21 ??? 0x0 Element.updateChild (framework.dart:2759)
22 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
23 ??? 0x0 Element.inflateWidget (framework.dart:2956)
24 ??? 0x0 MultiChildRenderObjectElement.mount (framework.dart:4982)
25 ??? 0x0 Element.inflateWidget (framework.dart:2956)
26 ??? 0x0 Element.updateChild (framework.dart:2759)
27 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
28 ??? 0x0 Element.rebuild (framework.dart:3559)
29 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
30 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
31 ??? 0x0 ComponentElement.mount (framework.dart:3711)
32 ??? 0x0 Element.inflateWidget (framework.dart:2956)
33 ??? 0x0 Element.updateChild (framework.dart:2759)
34 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
35 ??? 0x0 Element.inflateWidget (framework.dart:2956)
36 ??? 0x0 Element.updateChild (framework.dart:2759)
37 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
38 ??? 0x0 Element.rebuild (framework.dart:3559)
39 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
40 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
41 ??? 0x0 ComponentElement.mount (framework.dart:3711)
42 ??? 0x0 Element.inflateWidget (framework.dart:2956)
43 ??? 0x0 Element.updateChild (framework.dart:2759)
44 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
45 ??? 0x0 Element.inflateWidget (framework.dart:2956)
46 ??? 0x0 Element.updateChild (framework.dart:2759)
47 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
48 ??? 0x0 Element.rebuild (framework.dart:3559)
49 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
50 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
51 ??? 0x0 ComponentElement.mount (framework.dart:3711)
52 ??? 0x0 Element.inflateWidget (framework.dart:2956)
53 ??? 0x0 Element.updateChild (framework.dart:2759)
54 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
55 ??? 0x0 Element.inflateWidget (framework.dart:2956)
56 ??? 0x0 Element.updateChild (framework.dart:2759)
57 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
58 ??? 0x0 Element.rebuild (framework.dart:3559)
59 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
60 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
61 ??? 0x0 ComponentElement.mount (framework.dart:3711)
62 ??? 0x0 Element.inflateWidget (framework.dart:2956)
63 ??? 0x0 Element.updateChild (framework.dart:2759)
64 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
65 ??? 0x0 Element.rebuild (framework.dart:3559)
66 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
67 ??? 0x0 ComponentElement.mount (framework.dart:3711)
68 ??? 0x0 Element.inflateWidget (framework.dart:2956)
69 ??? 0x0 Element.updateChild (framework.dart:2759)
70 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
71 ??? 0x0 Element.rebuild (framework.dart:3559)
72 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
73 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
74 ??? 0x0 ComponentElement.mount (framework.dart:3711)
75 ??? 0x0 Element.inflateWidget (framework.dart:2956)
76 ??? 0x0 Element.updateChild (framework.dart:2759)
77 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
78 ??? 0x0 Element.inflateWidget (framework.dart:2956)
79 ??? 0x0 Element.updateChild (framework.dart:2759)
80 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
81 ??? 0x0 Element.rebuild (framework.dart:3559)
82 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
83 ??? 0x0 ComponentElement.mount (framework.dart:3711)
84 ??? 0x0 Element.inflateWidget (framework.dart:2956)
85 ??? 0x0 Element.updateChild (framework.dart:2759)
86 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
87 ??? 0x0 Element.inflateWidget (framework.dart:2956)
88 ??? 0x0 Element.updateChild (framework.dart:2759)
89 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
90 ??? 0x0 Element.rebuild (framework.dart:3559)
91 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
92 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
93 ??? 0x0 ComponentElement.mount (framework.dart:3711)
94 ??? 0x0 Element.inflateWidget (framework.dart:2956)
95 ??? 0x0 Element.updateChild (framework.dart:2759)
96 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
97 ??? 0x0 Element.rebuild (framework.dart:3559)
98 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
99 ??? 0x0 ComponentElement.mount (framework.dart:3711)
100 ??? 0x0 Element.inflateWidget (framework.dart:2956)
101 ??? 0x0 Element.updateChild (framework.dart:2759)
102 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
103 ??? 0x0 Element.inflateWidget (framework.dart:2956)
104 ??? 0x0 Element.updateChild (framework.dart:2759)
105 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
106 ??? 0x0 Element.rebuild (framework.dart:3559)
107 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
108 ??? 0x0 ComponentElement.mount (framework.dart:3711)
109 ??? 0x0 Element.inflateWidget (framework.dart:2956)
110 ??? 0x0 Element.updateChild (framework.dart:2759)
111 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
112 ??? 0x0 Element.rebuild (framework.dart:3559)
113 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
114 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
115 ??? 0x0 ComponentElement.mount (framework.dart:3711)
116 ??? 0x0 Element.inflateWidget (framework.dart:2956)
117 ??? 0x0 Element.updateChild (framework.dart:2759)
118 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
119 ??? 0x0 Element.rebuild (framework.dart:3559)
120 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
121 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
122 ??? 0x0 ComponentElement.mount (framework.dart:3711)
123 ??? 0x0 Element.inflateWidget (framework.dart:2956)
124 ??? 0x0 MultiChildRenderObjectElement.mount (framework.dart:4982)
125 ??? 0x0 Element.inflateWidget (framework.dart:2956)
126 ??? 0x0 Element.updateChild (framework.dart:2759)
127 ??? 0x0 _TheatreElement.mount (overlay.dart:494)
128 ??? 0x0 Element.inflateWidget (framework.dart:2956)
129 ??? 0x0 Element.updateChild (framework.dart:2759)
130 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
131 ??? 0x0 Element.rebuild (framework.dart:3559)
132 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
133 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
134 ??? 0x0 ComponentElement.mount (framework.dart:3711)
135 ??? 0x0 Element.inflateWidget (framework.dart:2956)
136 ??? 0x0 Element.updateChild (framework.dart:2759)
137 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
138 ??? 0x0 Element.rebuild (framework.dart:3559)
139 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
140 ??? 0x0 ComponentElement.mount (framework.dart:3711)
141 ??? 0x0 Element.inflateWidget (framework.dart:2956)
142 ??? 0x0 Element.updateChild (framework.dart:2759)
143 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
144 ??? 0x0 Element.inflateWidget (framework.dart:2956)
145 ??? 0x0 Element.updateChild (framework.dart:2759)
146 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
147 ??? 0x0 Element.rebuild (framework.dart:3559)
148 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
149 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
150 ??? 0x0 ComponentElement.mount (framework.dart:3711)
151 ??? 0x0 Element.inflateWidget (framework.dart:2956)
152 ??? 0x0 Element.updateChild (framework.dart:2759)
153 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
154 ??? 0x0 Element.inflateWidget (framework.dart:2956)
155 ??? 0x0 Element.updateChild (framework.dart:2759)
156 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
157 ??? 0x0 Element.inflateWidget (framework.dart:2956)
158 ??? 0x0 Element.updateChild (framework.dart:2759)
159 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
160 ??? 0x0 Element.rebuild (framework.dart:3559)
161 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
162 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
163 ??? 0x0 ComponentElement.mount (framework.dart:3711)
164 ??? 0x0 Element.inflateWidget (framework.dart:2956)
165 ??? 0x0 Element.updateChild (framework.dart:2759)
166 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
167 ??? 0x0 Element.rebuild (framework.dart:3559)
168 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
169 ??? 0x0 ComponentElement.mount (framework.dart:3711)
170 ??? 0x0 Element.inflateWidget (framework.dart:2956)
171 ??? 0x0 Element.updateChild (framework.dart:2759)
172 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
173 ??? 0x0 Element.rebuild (framework.dart:3559)
174 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
175 ??? 0x0 ComponentElement.mount (framework.dart:3711)
176 ??? 0x0 Element.inflateWidget (framework.dart:2956)
177 ??? 0x0 Element.updateChild (framework.dart:2759)
178 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
179 ??? 0x0 Element.rebuild (framework.dart:3559)
180 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
181 ??? 0x0 ComponentElement.mount (framework.dart:3711)
182 ??? 0x0 Element.inflateWidget (framework.dart:2956)
183 ??? 0x0 Element.updateChild (framework.dart:2759)
184 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
185 ??? 0x0 Element.rebuild (framework.dart:3559)
186 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
187 ??? 0x0 ComponentElement.mount (framework.dart:3711)
188 ??? 0x0 Element.inflateWidget (framework.dart:2956)
189 ??? 0x0 Element.updateChild (framework.dart:2759)
190 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
191 ??? 0x0 Element.rebuild (framework.dart:3559)
192 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
193 ??? 0x0 StatefulElement._firstBuild (framework.dart:3864)
194 ??? 0x0 ComponentElement.mount (framework.dart:3711)
195 ??? 0x0 Element.inflateWidget (framework.dart:2956)
196 ??? 0x0 Element.updateChild (framework.dart:2759)
197 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
198 ??? 0x0 Element.rebuild (framework.dart:3559)
199 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
200 ??? 0x0 ComponentElement.mount (framework.dart:3711)
201 ??? 0x0 Element.inflateWidget (framework.dart:2956)
202 ??? 0x0 Element.updateChild (framework.dart:2759)
203 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
204 ??? 0x0 Element.rebuild (framework.dart:3559)
205 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
206 ??? 0x0 ComponentElement.mount (framework.dart:3711)
207 ??? 0x0 Element.inflateWidget (framework.dart:2956)
208 ??? 0x0 Element.updateChild (framework.dart:2759)
209 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
210 ??? 0x0 Element.rebuild (framework.dart:3559)
211 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
212 ??? 0x0 ComponentElement.mount (framework.dart:3711)
213 ??? 0x0 Element.inflateWidget (framework.dart:2956)
214 ??? 0x0 Element.updateChild (framework.dart:2759)
215 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
216 ??? 0x0 Element.rebuild (framework.dart:3559)
217 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
218 ??? 0x0 ComponentElement.mount (framework.dart:3711)
219 ??? 0x0 Element.inflateWidget (framework.dart:2956)
220 ??? 0x0 Element.updateChild (framework.dart:2759)
221 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
222 ??? 0x0 Element.rebuild (framework.dart:3559)
223 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
224 ??? 0x0 ComponentElement.mount (framework.dart:3711)
225 ??? 0x0 Element.inflateWidget (framework.dart:2956)
226 ??? 0x0 Element.updateChild (framework.dart:2759)
227 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
228 ??? 0x0 Element.rebuild (framework.dart:3559)
229 ??? 0x0 ComponentElement._firstBuild (framework.dart:3716)
230 ??? 0x0 ComponentElement.mount (framework.dart:3711)
231 ??? 0x0 Element.inflateWidget (framework.dart:2956)
232 ??? 0x0 Element.updateChild (framework.dart:2759)
233 ??? 0x0 SingleChildRenderObjectElement.mount (framework.dart:4876)
234 ??? 0x0 Element.inflateWidget (framework.dart:2956)
235 ??? 0x0 Element.updateChild (framework.dart:2759)
236 ??? 0x0 ComponentElement.performRebuild (framework.dart:3747)
237 ??? 0x0 Element.rebuild (framework.dart:3559)
238 ??? 0x0 BuildOwner.buildScope (framework.dart:2273)
239 ??? 0x0 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (binding.dart:700)
240 ??? 0x0 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (binding.dart:268)
241 ??? 0x0 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (binding.dart:988)
242 ??? 0x0 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (binding.dart:928)
243 ??? 0x0 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame. (binding.dart:749)
244 ??? 0x0 ._rootRun (zone.dart:1120)
245 ??? 0x0 _CustomZone.run (zone.dart:1021)
246 ??? 0x0 _CustomZone.runGuarded (zone.dart:923)
247 ??? 0x0 _CustomZone.bindCallbackGuarded. (zone.dart:963)
248 ??? 0x0 ._rootRun (zone.dart:1124)
249 ??? 0x0 _CustomZone.run (zone.dart:1021)
250 ??? 0x0 _CustomZone.bindCallback. (zone.dart:947)
251 ??? 0x0 Timer._createTimer. (libtimer_patch.dart:21)
252 ??? 0x0 _Timer._runTimers (libtimer_impl.dart:382)
253 ??? 0x0 _Timer._handleMessage (libtimer_impl.dart:416)
254 ??? 0x0 _RawReceivePortImpl._handleMessage (libisolate_patch.dart:171)
I don't know what happend
the https://pub.dartlang.org/packages/encrypt#-analysis-tab- appear as
encrypt 0.2.0
Published Jul 3, 2018 DART 2 INCOMPATIBLE
i need to pass the encrypted text to nodejs backend, but I cant find any thing to decrypt it, any help?
RSAPublicKey.fromFile('public.pem');
if i only have a rsa public key ,how can i do decrypt
Hello leocavalcante,
I'm build a flutter APPοΌadd dependencies encrypt: ^2.2.0οΌ then 'flutter packages get' success, input code like:
final plainText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
final key = Key.fromUtf8('my 32 length key................');
final iv = IV.fromLength(16);
final encrypter = Encrypter(AES(key, iv));
final encrypted = encrypter.encrypt(plainText);
final decrypted = encrypter.decrypt(encrypted);
print(decrypted); // Lorem ipsum dolor sit amet, consectetur adipiscing elit
print(encrypted.base64); // R4PxiU3h8YoIRqVowBXm36ZcCeNeZ4s1OvVBTfFlZRdmohQqOpPQqD1YecJeZMAop/hZ4OxqgC1WtwvX/hP9mw==
but the Android Studio the error: 'The name 'Key' is defined in the libraries 'package:encrypt/encrypt.dart' and 'pack'. What's wrong?
Hi, I am using code, value - big variable
encrypter.decrypt64(value, iv: iv)
I tried to wrap the code in the future, but to no avail. The main thread is blocked
dec(value) {
var completer = new Completer();
completer.complete(encrypter.decrypt64(value, iv: iv));
return completer.future;
}
Hi Leo,
In Dart console app Salsa20 (Stream Cipher) works as expected. I try to add in my aqueduct project (pub spec.yaml) and I try to use pub get and fails for deflectable of dependance.....
My pub spec.yaml
name: niyazibankapi
description: An empty Aqueduct application.
version: 0.0.1
author: stable|kernel <[email protected]>
environment:
sdk: ">=2.0.0-dev <3.0.0"
dependencies:
aqueduct: ^3.0.0-beta.1
encrypt: ^0.2.0
dev_dependencies:
test: ^1.0.0
aqueduct_test: ^1.0.0-beta.1
dependency_overrides:
aqueduct:
path: /Users/niyazitoros/aqueduct/aqueduct/
aqueduct_test:
path: /Users/niyazitoros/aqueduct/aqueduct_test/
And the ERROR:
Niyazis-MacBook-Pro:niyazibankapiniyazitoros$ pub get
Resolving dependencies... (2.5s)
Because reflectable >=2.0.0 depends on analyzer ^0.31.0 and reflectable >=1.0.4 <=2.0.0-dev.1.0 depends on analyzer ^0.30.0, reflectable >=1.0.4 requires analyzer ^0.30.0 or ^0.31.0.
And because reflectable >=1.0.1 <1.0.4 depends on analyzer >=0.27.2 <0.30.0 and every version of aqueduct from path depends on analyzer ^0.32.0, aqueduct from path is incompatible with reflectable >=1.0.1.
And because every version of encrypt depends on pointycastle ^1.0.0-rc2 which depends on reflectable >=1.0.1 <3.0.0, aqueduct from path is incompatible with encrypt.
So, because niyazibankapidepends on both encrypt ^0.2.0 and aqueduct from path, version solving failed.
Niyazis-MacBook-Pro:niyazibankapiniyazitoros$
I want to use RSA and use "pub global active encrypt" create a keys, but I don't know what is maximum length to select.
In your RSA example you have public_key.pem and private_key.pem. What is maximum length I can get? Also I have a 2 mb reshape string. Can I encrypt that big string?
Thank you very much
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.