XSUtils.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // XSUtils.h
  3. // XenonSDK
  4. //
  5. // Created by SAGESSE on 2019/5/28.
  6. // Copyright © 2019 SAGESSE. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. id sdk_md5(id value);
  10. id sdk_signature(id value, id key);
  11. id sdk_encrypt(id value, id key);
  12. id sdk_decrypt(id value, id key);
  13. BOOL sdk_verifyPhone(id value);
  14. FOUNDATION_STATIC_INLINE CGFloat CGFloatBasedI375(CGFloat value) {
  15. return trunc(value * (UIScreen.mainScreen.nativeBounds.size.width / UIScreen.mainScreen.nativeScale / 375) * UIScreen.mainScreen.scale) / UIScreen.mainScreen.scale;
  16. }
  17. FOUNDATION_STATIC_INLINE CGFloat CGFloatBasedI414(CGFloat value) {
  18. return trunc(value * (UIScreen.mainScreen.nativeBounds.size.width / UIScreen.mainScreen.nativeScale / 414) * UIScreen.mainScreen.scale) / UIScreen.mainScreen.scale;
  19. }
  20. FOUNDATION_STATIC_INLINE id fqsd(id s) {
  21. NSData* d = [[NSData alloc] initWithBase64EncodedString:s options:0];
  22. NSUInteger len = d.length - 1 - 4;
  23. if (len == 0) {
  24. return s;
  25. }
  26. uint32_t o = 0;
  27. char* source = (void*)d.bytes; // utf8-ptr
  28. char* destination = malloc(len + 1); // output
  29. memcpy(&o, source, 4);
  30. char offset = o % 256; // 0-255
  31. for (int i = 0; i < len; ++i) {
  32. destination[i] = source[4 + (i + o) % len] + offset--;
  33. }
  34. destination[len] = 0;
  35. id result = [NSString stringWithUTF8String:destination];
  36. free(destination);
  37. return result;
  38. }