s.dart 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import 'package:bbyyy/https/MyDio.dart';
  2. import 'package:bbyyy/my_tools/my_cookie.dart';
  3. import 'package:encrypt/encrypt.dart';
  4. class s {
  5. encryption() {
  6. // print('encryption=========================================');
  7. String timestamp = MyCookie().prefs.getString('timestamp');
  8. String uid = MyCookie().prefs.getString('uid');
  9. String s = timestamp.replaceRange(0, uid.length, uid);
  10. // print(timestamp);
  11. // print(uid);
  12. // print(s);
  13. // print(s.substring(0, 16));
  14. // print(s.substring(16, s.length));
  15. var sk = s.substring(0, 16);
  16. var sv = s.substring(16);
  17. // print(sk);
  18. // print(sv);
  19. final key = Key.fromUtf8(sk);
  20. final iv = IV.fromUtf8(sv);
  21. final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
  22. // print('MyCookie().prefs.getString(using)==============${MyCookie().prefs.getString('using')}');
  23. String using = MyCookie().prefs.getString('using').split(',').last;
  24. var decrypt16 = encrypter.decrypt64(using, iv: iv);
  25. // print(decrypt16);
  26. MyCookie().server = decrypt16.split(':')[1];
  27. // if(MyCookie().server=='bby.banghuo.net'){
  28. // MyCookie().server = '172.162.104.19';
  29. // }
  30. // if(MyCookie().server=='localhost'){
  31. // MyCookie().server = '172.163.104.19';
  32. // }
  33. MyCookie().prefs.setString('serverID', decrypt16.split(':')[0]);
  34. MyDio().initDio();
  35. // print('encryption=========================================');
  36. }
  37. }