AES Encryption in dart 2
up vote
2
down vote
favorite
I've been trying to Encrypt a string using encrypt to send it to a webserver but i kept getting errors.
this is my function :
void encRypt(String da){
final key = "my32lengthsupersecretnooneknows1";
final encrypter = new Encrypter(new AES(key));
final encrypted = encrypter.encrypt(da);
print(encrypted);
}
this is how i used my function :
encRypt(chatBody.text);
and chatBody is a TextEditingController
the main errors
this my Debug Console :
Launching lib/main.dart on GT I9500 in debug mode...
Built build/app/outputs/apk/debug/app-debug.apk.
I/Timeline(19551): Timeline: Activity_idle id: android.os.BinderProxy@34db68a4 time:15254411
E/ (19551): [android_ws] Format: 5, Width: 1080, Height: 1920
E/ (19551): [android_ws] Format: 5, Width: 1080, Height: 1920
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
E/flutter (19551): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter (19551): Invalid argument(s): Input buffer too short
E/flutter (19551): #0 AESFastEngine.processBlock (package:pointycastle/block/aes_fast.dart:113:7)
E/flutter (19551): #1 AES._processBlocks (package:encrypt/src/aes.dart:42:25)
E/flutter (19551): #2 AES.encrypt (package:encrypt/src/aes.dart:22:20)
E/flutter (19551): #3 Encrypter.encrypt (package:encrypt/encrypt.dart:17:17)
E/flutter (19551): #4 StartPageState.encRypt (file:///home/sofiane/flutter/prog/testone/lib/pages/startpage.dart:28:29)
E/flutter (19551): #5 StartPageState.getData (file:///home/sofiane/flutter/prog/testone/lib/pages/startpage.dart:39:6)
E/flutter (19551): <asynchronous suspension>
E/flutter (19551): #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (19551): #7 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (19551): #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (19551): #9 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (19551): #10 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
E/flutter (19551): #11 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
E/flutter (19551): #12 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter (19551): #13 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter (19551): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
E/flutter (19551): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter (19551): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (19551): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter (19551): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter (19551): #19 _invoke1 (dart:ui/hooks.dart:153:13)
E/flutter (19551): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:107:5)
V/ActivityThread(19551): updateVisibility : ActivityRecord{1fd79a2f token=android.os.BinderProxy@34db68a4 {com.example.testone/com.example.testone.MainActivity}} show : true
Application finished.
Exited (sigint)
I tried everything as the example was shown on the github page of the package encrypt github it didn't work.
android encryption dart flutter
add a comment |
up vote
2
down vote
favorite
I've been trying to Encrypt a string using encrypt to send it to a webserver but i kept getting errors.
this is my function :
void encRypt(String da){
final key = "my32lengthsupersecretnooneknows1";
final encrypter = new Encrypter(new AES(key));
final encrypted = encrypter.encrypt(da);
print(encrypted);
}
this is how i used my function :
encRypt(chatBody.text);
and chatBody is a TextEditingController
the main errors
this my Debug Console :
Launching lib/main.dart on GT I9500 in debug mode...
Built build/app/outputs/apk/debug/app-debug.apk.
I/Timeline(19551): Timeline: Activity_idle id: android.os.BinderProxy@34db68a4 time:15254411
E/ (19551): [android_ws] Format: 5, Width: 1080, Height: 1920
E/ (19551): [android_ws] Format: 5, Width: 1080, Height: 1920
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
E/flutter (19551): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter (19551): Invalid argument(s): Input buffer too short
E/flutter (19551): #0 AESFastEngine.processBlock (package:pointycastle/block/aes_fast.dart:113:7)
E/flutter (19551): #1 AES._processBlocks (package:encrypt/src/aes.dart:42:25)
E/flutter (19551): #2 AES.encrypt (package:encrypt/src/aes.dart:22:20)
E/flutter (19551): #3 Encrypter.encrypt (package:encrypt/encrypt.dart:17:17)
E/flutter (19551): #4 StartPageState.encRypt (file:///home/sofiane/flutter/prog/testone/lib/pages/startpage.dart:28:29)
E/flutter (19551): #5 StartPageState.getData (file:///home/sofiane/flutter/prog/testone/lib/pages/startpage.dart:39:6)
E/flutter (19551): <asynchronous suspension>
E/flutter (19551): #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (19551): #7 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (19551): #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (19551): #9 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (19551): #10 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
E/flutter (19551): #11 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
E/flutter (19551): #12 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter (19551): #13 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter (19551): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
E/flutter (19551): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter (19551): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (19551): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter (19551): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter (19551): #19 _invoke1 (dart:ui/hooks.dart:153:13)
E/flutter (19551): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:107:5)
V/ActivityThread(19551): updateVisibility : ActivityRecord{1fd79a2f token=android.os.BinderProxy@34db68a4 {com.example.testone/com.example.testone.MainActivity}} show : true
Application finished.
Exited (sigint)
I tried everything as the example was shown on the github page of the package encrypt github it didn't work.
android encryption dart flutter
Isda
null or empty maybe?
– TheWanderer
Nov 9 at 14:54
@TheWanderer no its not empty its a string
– sofiane khoudour
Nov 9 at 14:56
Do you know the exact value of the String (can you edit it into your question)?
– TheWanderer
Nov 9 at 14:57
I also notice one thing you're doing differently. The example uses single quotes for Strings, while your encryption key is using double quotes. I don't remember if that matters in Dart or not.
– TheWanderer
Nov 9 at 14:58
i edit the code , i'm learning Dart so i dont really know if it matters or not :)
– sofiane khoudour
Nov 9 at 15:00
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I've been trying to Encrypt a string using encrypt to send it to a webserver but i kept getting errors.
this is my function :
void encRypt(String da){
final key = "my32lengthsupersecretnooneknows1";
final encrypter = new Encrypter(new AES(key));
final encrypted = encrypter.encrypt(da);
print(encrypted);
}
this is how i used my function :
encRypt(chatBody.text);
and chatBody is a TextEditingController
the main errors
this my Debug Console :
Launching lib/main.dart on GT I9500 in debug mode...
Built build/app/outputs/apk/debug/app-debug.apk.
I/Timeline(19551): Timeline: Activity_idle id: android.os.BinderProxy@34db68a4 time:15254411
E/ (19551): [android_ws] Format: 5, Width: 1080, Height: 1920
E/ (19551): [android_ws] Format: 5, Width: 1080, Height: 1920
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
E/flutter (19551): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter (19551): Invalid argument(s): Input buffer too short
E/flutter (19551): #0 AESFastEngine.processBlock (package:pointycastle/block/aes_fast.dart:113:7)
E/flutter (19551): #1 AES._processBlocks (package:encrypt/src/aes.dart:42:25)
E/flutter (19551): #2 AES.encrypt (package:encrypt/src/aes.dart:22:20)
E/flutter (19551): #3 Encrypter.encrypt (package:encrypt/encrypt.dart:17:17)
E/flutter (19551): #4 StartPageState.encRypt (file:///home/sofiane/flutter/prog/testone/lib/pages/startpage.dart:28:29)
E/flutter (19551): #5 StartPageState.getData (file:///home/sofiane/flutter/prog/testone/lib/pages/startpage.dart:39:6)
E/flutter (19551): <asynchronous suspension>
E/flutter (19551): #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (19551): #7 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (19551): #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (19551): #9 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (19551): #10 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
E/flutter (19551): #11 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
E/flutter (19551): #12 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter (19551): #13 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter (19551): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
E/flutter (19551): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter (19551): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (19551): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter (19551): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter (19551): #19 _invoke1 (dart:ui/hooks.dart:153:13)
E/flutter (19551): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:107:5)
V/ActivityThread(19551): updateVisibility : ActivityRecord{1fd79a2f token=android.os.BinderProxy@34db68a4 {com.example.testone/com.example.testone.MainActivity}} show : true
Application finished.
Exited (sigint)
I tried everything as the example was shown on the github page of the package encrypt github it didn't work.
android encryption dart flutter
I've been trying to Encrypt a string using encrypt to send it to a webserver but i kept getting errors.
this is my function :
void encRypt(String da){
final key = "my32lengthsupersecretnooneknows1";
final encrypter = new Encrypter(new AES(key));
final encrypted = encrypter.encrypt(da);
print(encrypted);
}
this is how i used my function :
encRypt(chatBody.text);
and chatBody is a TextEditingController
the main errors
this my Debug Console :
Launching lib/main.dart on GT I9500 in debug mode...
Built build/app/outputs/apk/debug/app-debug.apk.
I/Timeline(19551): Timeline: Activity_idle id: android.os.BinderProxy@34db68a4 time:15254411
E/ (19551): [android_ws] Format: 5, Width: 1080, Height: 1920
E/ (19551): [android_ws] Format: 5, Width: 1080, Height: 1920
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl(19551): ViewPostImeInputStage ACTION_DOWN
E/flutter (19551): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter (19551): Invalid argument(s): Input buffer too short
E/flutter (19551): #0 AESFastEngine.processBlock (package:pointycastle/block/aes_fast.dart:113:7)
E/flutter (19551): #1 AES._processBlocks (package:encrypt/src/aes.dart:42:25)
E/flutter (19551): #2 AES.encrypt (package:encrypt/src/aes.dart:22:20)
E/flutter (19551): #3 Encrypter.encrypt (package:encrypt/encrypt.dart:17:17)
E/flutter (19551): #4 StartPageState.encRypt (file:///home/sofiane/flutter/prog/testone/lib/pages/startpage.dart:28:29)
E/flutter (19551): #5 StartPageState.getData (file:///home/sofiane/flutter/prog/testone/lib/pages/startpage.dart:39:6)
E/flutter (19551): <asynchronous suspension>
E/flutter (19551): #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (19551): #7 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (19551): #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (19551): #9 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (19551): #10 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
E/flutter (19551): #11 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
E/flutter (19551): #12 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter (19551): #13 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter (19551): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
E/flutter (19551): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter (19551): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (19551): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter (19551): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter (19551): #19 _invoke1 (dart:ui/hooks.dart:153:13)
E/flutter (19551): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:107:5)
V/ActivityThread(19551): updateVisibility : ActivityRecord{1fd79a2f token=android.os.BinderProxy@34db68a4 {com.example.testone/com.example.testone.MainActivity}} show : true
Application finished.
Exited (sigint)
I tried everything as the example was shown on the github page of the package encrypt github it didn't work.
android encryption dart flutter
android encryption dart flutter
edited Nov 9 at 15:00
asked Nov 9 at 14:48
sofiane khoudour
134
134
Isda
null or empty maybe?
– TheWanderer
Nov 9 at 14:54
@TheWanderer no its not empty its a string
– sofiane khoudour
Nov 9 at 14:56
Do you know the exact value of the String (can you edit it into your question)?
– TheWanderer
Nov 9 at 14:57
I also notice one thing you're doing differently. The example uses single quotes for Strings, while your encryption key is using double quotes. I don't remember if that matters in Dart or not.
– TheWanderer
Nov 9 at 14:58
i edit the code , i'm learning Dart so i dont really know if it matters or not :)
– sofiane khoudour
Nov 9 at 15:00
add a comment |
Isda
null or empty maybe?
– TheWanderer
Nov 9 at 14:54
@TheWanderer no its not empty its a string
– sofiane khoudour
Nov 9 at 14:56
Do you know the exact value of the String (can you edit it into your question)?
– TheWanderer
Nov 9 at 14:57
I also notice one thing you're doing differently. The example uses single quotes for Strings, while your encryption key is using double quotes. I don't remember if that matters in Dart or not.
– TheWanderer
Nov 9 at 14:58
i edit the code , i'm learning Dart so i dont really know if it matters or not :)
– sofiane khoudour
Nov 9 at 15:00
Is
da
null or empty maybe?– TheWanderer
Nov 9 at 14:54
Is
da
null or empty maybe?– TheWanderer
Nov 9 at 14:54
@TheWanderer no its not empty its a string
– sofiane khoudour
Nov 9 at 14:56
@TheWanderer no its not empty its a string
– sofiane khoudour
Nov 9 at 14:56
Do you know the exact value of the String (can you edit it into your question)?
– TheWanderer
Nov 9 at 14:57
Do you know the exact value of the String (can you edit it into your question)?
– TheWanderer
Nov 9 at 14:57
I also notice one thing you're doing differently. The example uses single quotes for Strings, while your encryption key is using double quotes. I don't remember if that matters in Dart or not.
– TheWanderer
Nov 9 at 14:58
I also notice one thing you're doing differently. The example uses single quotes for Strings, while your encryption key is using double quotes. I don't remember if that matters in Dart or not.
– TheWanderer
Nov 9 at 14:58
i edit the code , i'm learning Dart so i dont really know if it matters or not :)
– sofiane khoudour
Nov 9 at 15:00
i edit the code , i'm learning Dart so i dont really know if it matters or not :)
– sofiane khoudour
Nov 9 at 15:00
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, So you can try to use Salsa20 instead
- the issue
1
Thanks for you answer, yes this is the solution
– sofiane khoudour
Nov 9 at 22:11
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, So you can try to use Salsa20 instead
- the issue
1
Thanks for you answer, yes this is the solution
– sofiane khoudour
Nov 9 at 22:11
add a comment |
up vote
0
down vote
accepted
AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, So you can try to use Salsa20 instead
- the issue
1
Thanks for you answer, yes this is the solution
– sofiane khoudour
Nov 9 at 22:11
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, So you can try to use Salsa20 instead
- the issue
AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, So you can try to use Salsa20 instead
- the issue
answered Nov 9 at 15:33
Raouf Rahiche
3,1112925
3,1112925
1
Thanks for you answer, yes this is the solution
– sofiane khoudour
Nov 9 at 22:11
add a comment |
1
Thanks for you answer, yes this is the solution
– sofiane khoudour
Nov 9 at 22:11
1
1
Thanks for you answer, yes this is the solution
– sofiane khoudour
Nov 9 at 22:11
Thanks for you answer, yes this is the solution
– sofiane khoudour
Nov 9 at 22:11
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53227992%2faes-encryption-in-dart-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is
da
null or empty maybe?– TheWanderer
Nov 9 at 14:54
@TheWanderer no its not empty its a string
– sofiane khoudour
Nov 9 at 14:56
Do you know the exact value of the String (can you edit it into your question)?
– TheWanderer
Nov 9 at 14:57
I also notice one thing you're doing differently. The example uses single quotes for Strings, while your encryption key is using double quotes. I don't remember if that matters in Dart or not.
– TheWanderer
Nov 9 at 14:58
i edit the code , i'm learning Dart so i dont really know if it matters or not :)
– sofiane khoudour
Nov 9 at 15:00