Chat Fixes & Chat Media Preview Api Implementation / On Msg Received Image

sultan-dev
Aamir Muhammad 2 years ago
parent ab6c221cdb
commit cecb2d59e9

@ -28,9 +28,7 @@ class ChatApiClient {
"password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG",
},
);
user.UserAutoLoginModel userLoginResponse = user.userAutoLoginModelFromJson(
response.body,
);
user.UserAutoLoginModel userLoginResponse = user.userAutoLoginModelFromJson(response.body);
return userLoginResponse;
}
@ -42,9 +40,7 @@ class ChatApiClient {
return searchUserJsonModel(response.body);
}
List<ChatUser> searchUserJsonModel(String str) => List<ChatUser>.from(
json.decode(str).map((x) => ChatUser.fromJson(x)),
);
List<ChatUser> searchUserJsonModel(String str) => List<ChatUser>.from(json.decode(str).map((x) => ChatUser.fromJson(x)));
Future<ChatUserModel> getRecentChats() async {
try {
@ -58,7 +54,6 @@ class ChatApiClient {
} catch (e) {
e as APIException;
if (e.message == "api_common_unauthorized") {
logger.d("Token Generated On APIIIIII");
user.UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserLoginToken();
if (userLoginResponse.response != null) {
AppState().setchatUserDetails = userLoginResponse;
@ -98,9 +93,7 @@ class ChatApiClient {
AppState().setchatUserDetails = userLoginResponse;
getSingleUserChatHistory(senderUID: senderUID, receiverUID: receiverUID, loadMore: loadMore, paginationVal: paginationVal);
} else {
Utils.showToast(
userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr",
);
Utils.showToast(userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr");
}
}
throw e;
@ -108,13 +101,7 @@ class ChatApiClient {
}
Future<fav.FavoriteChatUser> favUser({required int userID, required int targetUserID}) async {
Response response = await ApiClient().postJsonForResponse(
"${ApiConsts.chatFavUser}addFavUser",
{
"targetUserId": targetUserID,
"userId": userID,
},
token: AppState().chatDetails!.response!.token);
Response response = await ApiClient().postJsonForResponse("${ApiConsts.chatFavUser}addFavUser", {"targetUserId": targetUserID, "userId": userID}, token: AppState().chatDetails!.response!.token);
fav.FavoriteChatUser favoriteChatUser = fav.FavoriteChatUser.fromRawJson(response.body);
return favoriteChatUser;
}
@ -137,9 +124,7 @@ class ChatApiClient {
AppState().setchatUserDetails = userLoginResponse;
unFavUser(userID: userID, targetUserID: targetUserID);
} else {
Utils.showToast(
userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr",
);
Utils.showToast(userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr");
}
}
throw e;

@ -62,4 +62,5 @@ class MyColors {
static const Color grey9DColor = Color(0xff9D9D9D);
static const Color darkDigitColor = Color(0xff2D2F39);
static const Color grey71Color = Color(0xff717171);
static const Color darkGrey3BColor = Color(0xff3B3B3B);
}

@ -2,8 +2,8 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart';
class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server
static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
// static String baseUrl = "https://hmgwebservices.com"; // Live server
//static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
static String baseUrl = "https://hmgwebservices.com"; // Live server
static String baseUrlServices = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/";

@ -5,20 +5,15 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart';
import 'package:logging/logging.dart';
import 'package:mohem_flutter_app/api/chat/chat_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/consts.dart';
import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/exceptions/api_exception.dart';
import 'package:mohem_flutter_app/main.dart';
import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.dart';
import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.dart';
import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart' as login;
import 'package:mohem_flutter_app/models/chat/make_user_favotire_unfavorite_chat_model.dart' as fav;
import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart';
import 'package:mohem_flutter_app/widgets/image_picker.dart';
import 'package:signalr_netcore/signalr_client.dart';
import 'package:uuid/uuid.dart';
class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
@ -92,12 +87,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
if (isNewChat) userChatHistory = [];
if (!loadMore) paginationVal = 0;
isChatScreenActive = true;
Response response = await ChatApiClient().getSingleUserChatHistory(
senderUID: senderUID,
receiverUID: receiverUID,
loadMore: loadMore,
paginationVal: paginationVal,
);
Response response = await ChatApiClient().getSingleUserChatHistory(senderUID: senderUID, receiverUID: receiverUID, loadMore: loadMore, paginationVal: paginationVal);
if (response.statusCode == 204) {
if (isNewChat) {
userChatHistory = [];
@ -107,25 +97,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
} else {
if (loadMore) {
List<SingleUserChatModel> temp = getSingleUserChatModel(
response.body,
).reversed.toList();
userChatHistory.addAll(
temp,
);
List<SingleUserChatModel> temp = getSingleUserChatModel(response.body).reversed.toList();
userChatHistory.addAll(temp);
} else {
userChatHistory = getSingleUserChatModel(
response.body,
).reversed.toList();
userChatHistory = getSingleUserChatModel(response.body).reversed.toList();
}
}
isLoading = false;
notifyListeners();
markRead(
userChatHistory,
receiverUID,
);
markRead(userChatHistory, receiverUID);
generateConvId();
}
@ -139,13 +119,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
for (SingleUserChatModel element in data!) {
if (element.isSeen != null) {
if (!element.isSeen!) {
print("Found Un Read");
logger.d(jsonEncode(element));
dynamic data = [
{
"userChatHistoryId": element.userChatHistoryId,
"TargetUserId": element.targetUserId,
"isDelivered": true,
"isSeen": true,
}
{"userChatHistoryId": element.userChatHistoryId, "TargetUserId": element.targetUserId, "isDelivered": true, "isSeen": true}
];
updateUserChatHistoryStatusAsync(data);
}
@ -161,17 +138,22 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
void updateUserChatHistoryStatusAsync(List data) {
hubConnection.invoke(
"UpdateUserChatHistoryStatusAsync",
args: [data],
);
try {
hubConnection.invoke("UpdateUserChatHistoryStatusAsync", args: [data]);
} catch (e) {
throw e;
}
}
List<SingleUserChatModel> getSingleUserChatModel(String str) => List<SingleUserChatModel>.from(
json.decode(str).map(
(x) => SingleUserChatModel.fromJson(x),
),
);
void updateUserChatHistoryOnMsg(List data) {
try {
hubConnection.invoke("UpdateUserChatHistoryStatusAsync", args: [data]);
} catch (e) {
throw e;
}
}
List<SingleUserChatModel> getSingleUserChatModel(String str) => List<SingleUserChatModel>.from(json.decode(str).map((x) => SingleUserChatModel.fromJson(x)));
Future<dynamic> uploadAttachments(String userId, File file) async {
dynamic result;
@ -191,15 +173,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
void updateUserChatStatus(List<Object?>? args) {
dynamic items = args!.toList();
for (dynamic cItem in items[0]) {
for (var cItem in items[0]) {
for (SingleUserChatModel chat in userChatHistory) {
if (chat.userChatHistoryId.toString() == cItem["userChatHistoryId"].toString()) {
if (cItem["contantNo"].toString() == chat.contantNo.toString()) {
chat.isSeen = cItem["isSeen"];
chat.isDelivered = cItem["isDelivered"];
notifyListeners();
}
}
}
notifyListeners();
}
void onChatSeen(List<Object?>? args) {
@ -308,14 +290,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
userChatHistory.insert(0, data.first);
var list = [
{
"userChatHistoryId": data.first.userChatHistoryId,
"TargetUserId": data.first.targetUserId,
"isDelivered": true,
"isSeen": isChatScreenActive ? true : false,
}
{"userChatHistoryId": data.first.userChatHistoryId, "TargetUserId": temp.first.targetUserId, "isDelivered": true, "isSeen": isChatScreenActive ? true : false}
];
updateUserChatHistoryStatusAsync(list);
updateUserChatHistoryOnMsg(list);
notifyListeners();
}
@ -412,34 +389,34 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
Uint8List? image,
required bool isImageLoaded}) async {
Uuid uuid = const Uuid();
var contentNo = uuid.v4();
var msg = message.text;
SingleUserChatModel data = SingleUserChatModel(
chatEventId: chatEventId,
chatSource: 1,
contant: msg,
contantNo: uuid.v4(),
conversationId: chatCID,
createdDate: DateTime.now(),
currentUserId: AppState().chatDetails!.response!.id,
currentUserName: AppState().chatDetails!.response!.userName,
targetUserId: targetUserId,
targetUserName: targetUserName,
isReplied: false,
fileTypeId: fileTypeId,
userChatReplyResponse: isReply ? UserChatReplyResponse.fromJson(repliedMsg.first.toJson()) : null,
fileTypeResponse: isAttachment
? FileTypeResponse(
fileTypeId: fileTypeId,
fileTypeName: getFileType(getFileExtension(selectedFile.path).toString()),
fileKind: getFileExtension(selectedFile.path),
fileName: selectedFile.path.split("/").last,
fileTypeDescription: getFileTypeDescription(getFileExtension(selectedFile.path).toString()),
)
: null,
image: image,
isImageLoaded: isImageLoaded,
);
chatEventId: chatEventId,
chatSource: 1,
contant: msg,
contantNo: contentNo,
conversationId: chatCID,
createdDate: DateTime.now(),
currentUserId: AppState().chatDetails!.response!.id,
currentUserName: AppState().chatDetails!.response!.userName,
targetUserId: targetUserId,
targetUserName: targetUserName,
isReplied: false,
fileTypeId: fileTypeId,
userChatReplyResponse: isReply ? UserChatReplyResponse.fromJson(repliedMsg.first.toJson()) : null,
fileTypeResponse: isAttachment
? FileTypeResponse(
fileTypeId: fileTypeId,
fileTypeName: getFileType(getFileExtension(selectedFile.path).toString()),
fileKind: getFileExtension(selectedFile.path),
fileName: selectedFile.path.split("/").last,
fileTypeDescription: getFileTypeDescription(getFileExtension(selectedFile.path).toString()),
)
: null,
image: image,
isImageLoaded: isImageLoaded);
userChatHistory.insert(0, data);
isFileSelected = false;
isMsgReply = false;
@ -448,7 +425,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
notifyListeners();
String chatData =
'{"contant":"$msg","contantNo":"${uuid.v4()}","chatEventId":$chatEventId,"fileTypeId": $fileTypeId,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"userChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":$targetUserId,"targetUserStatus":1}],"chatReplyId":$chatReplyId,"conversationId":"$chatCID"}';
'{"contant":"$msg","contantNo":"$contentNo","chatEventId":$chatEventId,"fileTypeId": $fileTypeId,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"userChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":$targetUserId,"targetUserStatus":1}],"chatReplyId":$chatReplyId,"conversationId":"$chatCID"}';
await hubConnection.invoke("AddChatUserAsync", args: <Object>[json.decode(chatData)]);
}
@ -456,11 +433,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
dynamic contain = searchedChats!.where((ChatUser element) => element.id == targetUserId);
if (contain.isEmpty) {
searchedChats!.add(
ChatUser(
id: targetUserId,
userName: targetUserName,
unreadMessageCount: 0
),
ChatUser(id: targetUserId, userName: targetUserName, unreadMessageCount: 0),
);
notifyListeners();
}
@ -693,17 +666,21 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
// }
void msgScroll() {
scrollController.animateTo(
scrollController.position.minScrollExtent - 100,
duration: const Duration(milliseconds: 500),
curve: Curves.easeIn,
);
}
// Future<void> getDownLoadFile(String fileName) async {
// var data = await ChatApiClient().downloadURL(fileName: "data");
// Image.memory(data);
// }
// scrollController.animateTo(
// // index: 150,
// duration: Duration(seconds: 2),
// curve: Curves.easeInOutCubic);
// scrollController.animateTo(
// scrollController.position.minScrollExtent - 100,
// duration: const Duration(milliseconds: 500),
// curve: Curves.easeIn,
// );
}
// Future<void> getDownLoadFile(String fileName) async {
// var data = await ChatApiClient().downloadURL(fileName: "data");
// Image.memory(data);
// }
// void getUserChatHistoryNotDeliveredAsync({required int userId}) async {
// try {
@ -713,12 +690,4 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
// }
// }
}

@ -74,23 +74,41 @@ class ChatBubble extends StatelessWidget {
if (cItem.userChatReplyResponse != null && cItem.userChatReplyResponse!.fileTypeId == 12 ||
cItem.userChatReplyResponse!.fileTypeId == 3 ||
cItem.userChatReplyResponse!.fileTypeId == 4)
// Container(
// padding: EdgeInsets.all(0), // Border width
// decoration: BoxDecoration(color: Colors.red, borderRadius: const BorderRadius.all(Radius.circular(8))),
// child: ClipRRect(
// borderRadius: const BorderRadius.all(
// Radius.circular(8),
// ),
// child: SizedBox.fromSize(
// size: Size.fromRadius(8), // Image radius
// child: showImage(
// isReplyPreview: true,
// fileName: cItem.userChatReplyResponse!.contant!,
// fileTypeDescription: cItem.userChatReplyResponse!.fileTypeResponse!.fileTypeDescription ?? "image/jpg"),
// ),
// ),
// ),
ClipRRect(
borderRadius: BorderRadius.circular(
8,
borderRadius: BorderRadius.circular(8.0),
child: SizedBox(
height: 32,
width: 32,
child: showImage(
isReplyPreview: true,
fileName: cItem.userChatReplyResponse!.contant!,
fileTypeDescription: cItem.userChatReplyResponse!.fileTypeResponse!.fileTypeDescription ?? "image/jpg")
.paddingOnly(left: 10, right: 10, bottom: 16, top: 16),
),
child: showImage(
isReplyPreview: true,
fileName: cItem.userChatReplyResponse!.contant!,
fileTypeDescription: cItem.userChatReplyResponse!.fileTypeResponse!.fileTypeDescription ?? "image/jpg")
.paddingOnly(left: 10, right: 10, bottom: 16, top: 16),
)
),
],
),
),
).paddingOnly(right: 5, bottom: 7),
if (fileTypeID == 12 || fileTypeID == 4 || fileTypeID == 3)
showImage(isReplyPreview: false, fileName: cItem.contant!, fileTypeDescription: cItem.fileTypeResponse!.fileTypeDescription).paddingOnly(right: 5).onPress(() {
showDialog(context: context, builder: (index) => ChatImagePreviewScreen(imgTitle: cItem.contant!, img: cItem.image!));
showDialog(context: context, builder: (BuildContext context) => ChatImagePreviewScreen(imgTitle: cItem.contant!, img: cItem.image!));
}),
cItem.contant!.toText12(),
Align(
@ -110,7 +128,7 @@ class ChatBubble extends StatelessWidget {
).paddingOnly(top: 11, left: 13, right: 7, bottom: 5).objectContainerView(disablePadding: true).paddingOnly(left: MediaQuery.of(context).size.width * 0.3);
}
Widget receiptUser(context) {
Widget receiptUser(BuildContext context) {
return Container(
padding: const EdgeInsets.only(top: 11, left: 13, right: 7, bottom: 5),
decoration: BoxDecoration(
@ -153,27 +171,27 @@ class ChatBubble extends StatelessWidget {
cItem.userChatReplyResponse!.fileTypeId == 4)
ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: showImage(
child: SizedBox(
height: 32,
width: 32,
child: showImage(
isReplyPreview: true,
fileName: cItem.userChatReplyResponse!.contant!,
fileTypeDescription: cItem.userChatReplyResponse!.fileTypeResponse!.fileTypeDescription ?? "image/jpg")
.paddingOnly(left: 10, right: 10, bottom: 16, top: 16),
)
fileTypeDescription: cItem.userChatReplyResponse!.fileTypeResponse!.fileTypeDescription ?? "image/jpg")),
).paddingOnly(left: 10, right: 10, bottom: 16, top: 16)
],
),
),
).paddingOnly(right: 5, bottom: 7),
if (fileTypeID == 12 || fileTypeID == 4 || fileTypeID == 3)
showImage(isReplyPreview: false, fileName: cItem.contant!, fileTypeDescription: cItem.fileTypeResponse!.fileTypeDescription ?? "image/jpg").paddingOnly(right: 5).onPress(() {
showDialog(context: context, builder: (index) => ChatImagePreviewScreen(imgTitle: cItem.contant!, img: cItem.image!));
showDialog(context: context, builder: (BuildContext context) => ChatImagePreviewScreen(imgTitle: cItem.contant!, img: cItem.image!));
})
else
(cItem.contant! ?? "").toText12(color: Colors.white),
Align(
alignment: Alignment.centerRight,
child: dateTime.toText10(
color: Colors.white.withOpacity(.71),
),
child: dateTime.toText10(color: Colors.white.withOpacity(.71)),
),
],
),
@ -196,7 +214,6 @@ class ChatBubble extends StatelessWidget {
if (snapshot.data == null) {
return SizedBox();
} else {
//data = image;
cItem.image = snapshot.data;
cItem.isImageLoaded = true;
return Image.memory(

@ -221,14 +221,11 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
Widget showReplyImage(List<SingleUserChatModel> data) {
if (data.first.isImageLoaded! && data.first.image != null) {
return ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.memory(
data.first.image!,
height: 43,
width: 43,
fit: BoxFit.cover,
),
return Container(
width: 43,
height: 43,
decoration: BoxDecoration(
border: Border.all(color: MyColors.darkGrey3BColor, width: 1), borderRadius: BorderRadius.circular(10.0), image: DecorationImage(image: MemoryImage(data.first.image!), fit: BoxFit.cover)),
);
} else {
return const SizedBox();

@ -25,7 +25,8 @@ class ChatImagePreviewScreen extends StatelessWidget {
Image.memory(
img,
fit: BoxFit.cover,
height: 400,
width: double.infinity,
).paddingAll(10),
const Positioned(
right: 0,

@ -1,3 +1,4 @@
import 'dart:convert';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -210,6 +211,9 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
),
),
onPressed: () async {
// String plainText = 'Muhamad.Alam@cloudsolutions.com.sa';
// String key = "PeShVmYp";
// passEncrypt(plainText, "PeShVmYp");
showMyBottomSheet(
context,
callBackFunc: () {},
@ -237,4 +241,127 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
),
);
}
//
// void passEncrypt(String text, String pass) async {
// var salt = randomUint8List(8);
// var keyndIV = deriveKeyAndIV(pass, salt);
// var key = encrypt.Key(keyndIV.item1);
// var iv = encrypt.IV(keyndIV.item2);
// var encrypter = encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc, padding: "PKCS7"));
// var encrypted = encrypter.encrypt(text, iv: iv);
// Uint8List encryptedBytesWithSalt = Uint8List.fromList(createUint8ListFromString("Salted__") + salt + encrypted.bytes);
// var resulttt = base64.encode(encryptedBytesWithSalt);
// print("Enc : " + resulttt);
//
// decryptAESCryptoJS(resulttt, pass);
// }
//
// Uint8List randomUint8List(int length) {
// assert(length > 0);
// var random = Random();
// var ret = Uint8List(length);
// for (var i = 0; i < length; i++) {
// ret[i] = random.nextInt(256);
// }
// return ret;
// }
//
// void decryptAESCryptoJS(String encrypted, String passphrase) {
// try {
// Uint8List encryptedBytesWithSalt = base64.decode(encrypted);
// Uint8List encryptedBytes = encryptedBytesWithSalt.sublist(16, encryptedBytesWithSalt.length);
// var salt = encryptedBytesWithSalt.sublist(8, 16);
// var keyndIV = deriveKeyAndIV(passphrase, salt);
// var key = encrypt.Key(keyndIV.item1);
// var iv = encrypt.IV(keyndIV.item2);
// var encrypter = encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc, padding: "PKCS7"));
// var decrypted = encrypter.decrypt64(base64.encode(encryptedBytes), iv: iv);
// print("Dec : " + decrypted);
// // return decrypted;
// } catch (error) {
// throw error;
// }
// }
void enc(String input) {
var ekey = "PeShVmYp";
var eIV = "j70IbWYn";
List<int> eByt = utf8.encode(ekey);
List<int> eIvByt = utf8.encode(eIV);
List<int> iByt = utf8.encode(input);
}
// ///Accepts encrypted data and decrypt it. Returns plain text
// String decryptWithAES(String key, Encrypted encryptedData) {
// var cipherKey = encrypt.Key.fromUtf8(key);
// var encryptService = Encrypter(AES(cipherKey, mode: AESMode.cbc,padding: null));
// var initVector = IV.fromUtf8(key.substring(0, 16));
// return encryptService.decrypt(encryptedData, iv: initVector);
// }
//
// ///Encrypts the given plainText using the key. Returns encrypted data
// Encrypted encryptWithAES(String key, String plainText) {
// var cipherKey = encrypt.Key.fromUtf8(key);
// var encryptService = Encrypter(AES(cipherKey, mode: AESMode.cbc,padding: null));
// var initVector = IV.fromUtf8("j70IbWYn");
// Encrypted encryptedData = encryptService.encrypt(plainText, iv: initVector);
// print(encryptedData.base64);
// return encryptedData;
// }
//
// Tuple2<Uint8List, Uint8List> deriveKeyAndIV(String passphrase, Uint8List salt) {
// var password = createUint8ListFromString(passphrase);
// Uint8List concatenatedHashes = Uint8List(0);
// Uint8List currentHash = Uint8List(0);
// bool enoughBytesForKey = false;
// Uint8List preHash = Uint8List(0);
//
// while (!enoughBytesForKey) {
// int preHashLength = currentHash.length + password.length + salt.length;
// if (currentHash.length > 0)
// preHash = Uint8List.fromList(currentHash + password + salt);
// else
// preHash = Uint8List.fromList(password + salt);
//
// currentHash = preHash;
// concatenatedHashes = Uint8List.fromList(concatenatedHashes + currentHash);
// if (concatenatedHashes.length >= 48) enoughBytesForKey = true;
// }
//
// var keyBtyes = concatenatedHashes.sublist(0, 32);
// var ivBtyes = concatenatedHashes.sublist(32, 48);
// return new Tuple2(keyBtyes, ivBtyes);
// }
//
// Uint8List createUint8ListFromString(String s) {
// var ret = new Uint8List(s.length);
// for (var i = 0; i < s.length; i++) {
// ret[i] = s.codeUnitAt(i);
// }
// return ret;
// }
//
// Uint8List genRandomWithNonZero(int seedLength) {
// var random = Random.secure();
// const int randomMax = 245;
// Uint8List uint8list = Uint8List(seedLength);
// for (int i = 0; i < seedLength; i++) {
// uint8list[i] = random.nextInt(randomMax) + 1;
// }
// return uint8list;
// }
//
//
//
// void test(String text, String kk) {
// Uint8List key = Uint8List.fromList(utf8.encode(kk));
// PaddedBlockCipher cipher = exp.PaddedBlockCipherImpl(exp.PKCS7Padding(), exp.ECBBlockCipher(exp.AESEngine()));
// cipher.init(true, PaddedBlockCipherParameters<CipherParameters, CipherParameters>(KeyParameter(key), null));
// var byte = Uint8List.fromList(utf8.encode(text));
// var data = cipher.process(byte);
// print(data);
// }
}

@ -94,6 +94,9 @@ dependencies:
camera: ^0.10.0+4
#Encryption
cryptography: ^2.0.5
cryptography_flutter: ^2.0.2
video_player: ^2.4.7

Loading…
Cancel
Save