Quick.Base64.pas 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. { ***************************************************************************
  2. Copyright (c) 2016-2017 Kike Pérez
  3. Unit : Quick.Base64
  4. Description : Base64 functions
  5. Author : Kike Pérez
  6. Version : 1.1
  7. Created : 08/11/2017
  8. Modified : 14/08/2018
  9. This file is part of QuickLib: https://github.com/exilon/QuickLib
  10. ***************************************************************************
  11. Licensed under the Apache License, Version 2.0 (the "License");
  12. you may not use this file except in compliance with the License.
  13. You may obtain a copy of the License at
  14. http://www.apache.org/licenses/LICENSE-2.0
  15. Unless required by applicable law or agreed to in writing, software
  16. distributed under the License is distributed on an "AS IS" BASIS,
  17. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. See the License for the specific language governing permissions and
  19. limitations under the License.
  20. *************************************************************************** }
  21. unit Quick.Base64;
  22. {$i QuickLib.inc}
  23. interface
  24. uses
  25. {$IFDEF DELPHIXE7_UP}
  26. System.NetEncoding;
  27. {$ELSE}
  28. IdCoderMIME,
  29. IdGlobal;
  30. {$ENDIF}
  31. function Base64Encode(const Input: string): string;
  32. function Base64Decode(const Input: string): string;
  33. implementation
  34. function Base64Encode(const Input: string): string;
  35. begin
  36. {$IFDEF DELPHIXE7_UP}
  37. Result := TNetEncoding.Base64.Encode(Input);
  38. {$ELSE}
  39. Result := TIdEncoderMIME.EncodeString(Input,IndyTextEncoding_OSDefault);
  40. {$ENDIF}
  41. end;
  42. function Base64Decode(const Input: string): string;
  43. begin
  44. {$IFDEF DELPHIXE7_UP}
  45. Result := TNetEncoding.Base64.Decode(Input);
  46. {$ELSE}
  47. Result := TIdDecoderMIME.DecodeString(Input,IndyTextEncoding_OSDefault);
  48. {$ENDIF}
  49. end;
  50. end.