import 'EncryptUtil.dart'; import 'dart:convert'; class UserInfo { UserInfo({this.mapUserInfoRet}) { setUserInfo(theMapUserInfoRet: mapUserInfoRet); } setUserInfo({Map theMapUserInfoRet}) { if (200 == theMapUserInfoRet["ret"]) { mapUserInfoRet = theMapUserInfoRet; mapUserInfo = theMapUserInfoRet["data"]; print('mapUserInfo = ${mapUserInfo.toString()}'); } } //_mapGetData = {is_login: true, user_id: 135, token: 4C5B3F93FEACAEF4B6CAA7296F22CC67825D7E48B867614383D19E3F23DFE510} setUserInfoFaceLogin(Map _mapGetData) { mapUserInfo['user_id'] = _mapGetData['user_id']; mapUserInfo['token'] = _mapGetData['token']; } Map mapUserInfoRet = { "ret": 200, "data": { "is_login": true, "user_id": 1, "token": "B93EC91FA2FE293B7077162D4527FC4BB228CD6C0A4F24A882B9A8BBE6C3FB47" }, "msg": "" }; Map mapUserInfo = { "is_login": false, "user_id": -1, "token": "" }; //若list[i]为'',解密时会报错:aes decode error:RangeError: Value not in range: -16 String thisAndroidId = ''; //每个手机唯一的设备号 String username = ''; String password = ''; String userLoginInfo = ''; List userGroupIDlist = []; //用户所属组列表 Map userRulesMap = {}; //用户所属组的权限列表 String getUserinfoEncrypted2() { String userinfoEncrypted1 = EncryptUtil.aesEncode(thisAndroidId) + '\n' + EncryptUtil.aesEncode(username) + '\n' + EncryptUtil.aesEncode(password) + '\n' + EncryptUtil.aesEncode(userLoginInfo); String userinfoEncrypted2 = EncryptUtil.aesEncode(userinfoEncrypted1); return userinfoEncrypted2; } String getUserinfoDencrypted2(String userinfoEncrypted2) { String userinfoDencrypted1 = EncryptUtil.aesDecode(userinfoEncrypted2); List list = userinfoDencrypted1.split('\n'); int len = list.length; String userinfoDencrypted2 = ''; print('len = $len'); for (int i = 0; i < len; i++) { list[i] = EncryptUtil.aesDecode(list[i]); userinfoDencrypted2 += ('' == userinfoDencrypted2 ? '' : '\n') + list[i]; } return userinfoDencrypted2; } }