signData static method
数据签名
Implementation
static Future<Map<String, dynamic>> signData(
CloudBaseCore core, Map<String, dynamic> data) async {
final appAccess = core.config.appAccess;
String? secret = appAccess['key'];
String? version = appAccess['version'];
if (secret != null && version != null) {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String appSign = packageInfo.packageName;
int timestamp = DateTime.now().millisecondsSinceEpoch;
var payload = {
'data': data,
'timestamp': timestamp,
'appAccessKeyId': version,
'appSign': appSign
};
var sign = _createSign(payload, secret);
var newData = Map<String, dynamic>();
newData.addAll(data);
newData['timestamp'] = timestamp;
newData['appAccessKeyId'] = version;
newData['appSign'] = appSign;
newData['sign'] = sign;
return newData;
}
return data;
}