Skip to content

Instantly share code, notes, and snippets.

@gravejester
Created April 5, 2015 07:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravejester/e1c874f3579b166c1986 to your computer and use it in GitHub Desktop.
Save gravejester/e1c874f3579b166c1986 to your computer and use it in GitHub Desktop.
function Invoke-Base64UrlEncode {
<#
.SYNOPSIS
.DESCRIPTION
.NOTES
http://blog.securevideo.com/2013/06/04/implementing-json-web-tokens-in-net-with-a-base-64-url-encoded-key/
Author: Øyvind Kallstad
Date: 23.03.2015
Version: 1.0
#>
[CmdletBinding()]
param (
[Parameter(Position = 0, Mandatory)]
[byte[]] $Argument
)
$output = [System.Convert]::ToBase64String($Argument)
$output = $output.Split('=')[0]
$output = $output.Replace('+', '-')
$output = $output.Replace('/', '_')
Write-Output $output
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment