PPOTString.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // PPOTString.m
  3. // Copyright © 2015 PayPal, Inc. All rights reserved.
  4. //
  5. #import <Foundation/Foundation.h>
  6. #import <UIKit/UIKit.h>
  7. /**
  8. NSString helper used for PayPal payments
  9. */
  10. @interface PPOTString : NSObject
  11. /**
  12. URL encodes all characters in a given string including &, %, ?, =, and other URL "safe" characters
  13. @param aString the string to encode
  14. @return the encoded string
  15. */
  16. + (nonnull NSString *)stringByURLEncodingAllCharactersInString:(nonnull NSString *)aString;
  17. /**
  18. Base64 encoded version of the data
  19. @param data Data to base64 encode
  20. @return the base64 encoded data as a string
  21. */
  22. + (nonnull NSString *)stringByBase64EncodingData:(nonnull NSData *)data;
  23. /**
  24. Decoded a base64 string back into data
  25. @param strBase64 the string base64 encoded
  26. @return the decoded data
  27. */
  28. + (nullable NSData *)decodeBase64WithString:(nonnull NSString *)strBase64;
  29. /**
  30. Generates a random identifier
  31. @return a uniquish identifier
  32. */
  33. + (nonnull NSString *)generateUniquishIdentifier;
  34. /**
  35. Converts a NSData to a hexadecimal NSString
  36. @param data the data to convert
  37. @return a hexadecimal string from given byte data
  38. */
  39. + (nonnull NSString *)hexStringFromData:(nonnull NSData *)data;
  40. /**
  41. Converts a hexadecimal string into a NSData representation
  42. @param hexString the string to convert
  43. @return the converted value representation of the hexadecimal string
  44. */
  45. + (nonnull NSData *)dataWithHexString:(nonnull NSString *)hexString;
  46. @end