Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfset key = '943b421c9eb07c830af81030552c86009268de4e532ba2ee2eab8247c6da0881'>
- <cfset salt = '520f986b998545b4785e0defbc4f3c1203f22de2374a3d53cb7a7fe9fea309c5'>
- <!--- converting hexa to binary --->
- <cfset keyBin = #binaryDecode(key, 'hex')#>
- <!--- converting binary to string--->
- <cfset keyBin = #toString(keyBin)#>
- <cfif NOT isDefined("keyBin")>
- <cfabort showError = "Key expected to be hex-encoded string">
- </cfif>
- <!--- converting hexa to binary --->
- <cfset saltBin = #binaryDecode(salt, 'hex')#>
- <!--- converting binary to string--->
- <cfset saltBin = #toString(saltBin)#>
- <!--- <cfdump var="#saltBin#"> --->
- <cfif NOT isDefined("saltBin")>
- <cfabort showError = "Salt expected to be hex-encoded string">
- </cfif>
- <cfset resize = 'fill'>
- <cfset width = '300'>
- <cfset height = '300'>
- <cfset gravity = 'no'>
- <cfset enlarge = 1>
- <cfset extension = 'png'>
- <cfset imgurl = 'http://img.example.com/pretty/image.jpg'>
- <!--- <cfdump var= #ToBase64(imgurl)#> --->
- <cfset encoded = ToBase64(imgurl)>
- <cfset encoded = replaceNoCase(encoded, "+", "-",'ALL')>
- <cfset encoded = replaceNoCase(encoded, "/", "_",'ALL')>
- <cfset encoded = trim(encoded)>
- <cfif right(encoded, 1) is "=">
- <cfset encoded = left(encoded, len(encoded)-1)>
- </cfif>
- <!--- <cfdump var= #encoded#> --->
- <cfset path = "/rs:"&resize&":"&width&":"&height&":"&enlarge&"/g:"&gravity&"/"&encoded&"."&extension>
- <cfset abc = hmac(saltBin&path,keyBin,"HMACSHA256")>
- <cfoutput>#abc#</cfoutput>
- <!--- <cfoutput>#abc#</cfoutput> --->
- <!--- <cfoutput>#abc#</cfoutput> --->
- <cfabort>
- <!--- <!--- converting hexa to binary --->
- <cfset abc = #binaryDecode(abc, 'hex')#> --->
- <!--- converting binary to string--->
- <!--- cfset abc = binaryEncode( binaryDecode(abc, "hex"), "base64" )> --->
- <!--- <cfoutput>#binaryEncode( binaryDecode(abc, "hex"), "base64" )#</cfoutput> --->
- <cfabort>
- <!--- <cfset url = 'http://img.example.com/pretty/image.jpg'>
- $encodedUrl = rtrim(strtr(base64_encode($url), '+/', '-_'), '='); --->
Add Comment
Please, Sign In to add comment