Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfcomponent displayname="String" output="false" hint="String related functions.">
- <cffunction name="init" access="public" output="false" returntype="void">
- </cffunction>
- <cffunction name="Base64Encode" access="public" output="false" returntype="string" hint="Returns a Base64 encoded string.">
- <cfargument name="String" type="string" required="true" hint="String to encode.">
- <cfreturn BinaryEncode(CharsetDecode(Arguments.String, "utf-8"), "Base64")>
- </cffunction>
- <cffunction name="Base64Decode" access="public" output="false" returntype="string" hint="Returns a Base64 decoded string.">
- <cfargument name="String" type="string" required="true" hint="String to decode.">
- <cfreturn CharsetEncode(BinaryDecode(Arguments.String, "Base64"), "utf-8")>
- </cffunction>
- <cffunction name="Base64URLEncode" access="public" output="false" returntype="string" hint="Returns a base64url encoded string.">
- <cfargument name="String" type="string" required="true" hint="String to encode.">
- <cfreturn Replace( Replace( Replace( Variables.Base64Encode(Arguments.String), "=", "", "all"), "+", "-", "all"), "/", "_", "all")>
- </cffunction>
- <cffunction name="Base64URLDecode" access="public" output="false" returntype="string" hint="Returns a base64url decoded string.">
- <cfargument name="String" type="string" required="true" hint="String to decode.">
- <cfreturn Variables.Base64Decode( Replace( Replace( Arguments.String, "-", "+", "all"), "_", "/", "all") & RepeatString("=", Len(Arguments.String) + (4 - Len(Arguments.String) % 4) % 4))>
- </cffunction>
- </cfcomponent>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement