Skip to content

Instantly share code, notes, and snippets.

View gravejester's full-sized avatar

Øyvind Kallstad gravejester

View GitHub Profile
function Invoke-PathShortener {
<#
.SYNOPSIS
Path Shortener
.NOTES
Author: Øyvind Kallstad
Date: 05.04.2016
Version: 2
#>
[CmdletBinding()]
function Get-PackageUpdate {
[CmdletBinding()]
param (
[Parameter()]
[string] $Name,
[Parameter()]
[string] $ProviderName
)
param([Parameter(Position = 0)][string] $Path = 'C:\Users\grave\Downloads\ChessData-master\')
$code = @{
Name = 'ResultCounter'
Namespace = 'ChessData'
PassThru = $true
UsingNamespace = @(
'System.Collections.Concurrent',
'System.IO',
'System.Threading.Tasks'
)
function ConvertTo-Digits {
<#
.SYNOPSIS
Convert an integer into an array of bytes of its individual digits.
.DESCRIPTION
Convert an integer into an array of bytes of its individual digits.
.EXAMPLE
ConvertTo-Digits 145
.INPUTS
System.UInt64
function Get-LuhnChecksum {
<#
.SYNOPSIS
Calculate the Luhn checksum of a number.
.DESCRIPTION
The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm,
is a simple checksum formula used to validate a variety of identification numbers, such as
credit card numbers, IMEI numbers, National Provider Identifier numbers in the US, and
Canadian Social Insurance Numbers. It was created by IBM scientist Hans Peter Luhn.
.EXAMPLE
function Invoke-RepeatingKeyXOR {
# http://cryptopals.com/sets/1/challenges/5/
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[Alias('String')]
[string] $InputString,
[Parameter(Mandatory = $true, Position = 1)]
function ConvertTo-Bytes {
<#
.SYNOPSIS
Convert a string to bytes.
.NOTES
Author: Øyvind Kallstad
Date: 13.02.2016
Version: 1.0
#>
[CmdletBinding()]
function Get-Entropy {
<#
.SYNOPSIS
Calculate the entropy of a data set.
.DESCRIPTION
This function will calculate either the Shannon Entropy, or the
Metric Entropy of a data set.
.EXAMPLE
Get-Entropy -InputObject $myArray
Calculate the Shannon Entropy in the data in the myArray array.
function Remove-Characters {
<#
.SYNOPSIS
Remove characters from a string.
.DESCRIPTION
This function will take an array of characters, and will remove
those characters from the input string.
.EXAMPLE
$myString | Remove-Characters
This will remove all 'default' characters from myString.
function Measure-Frequency {
<#
.SYNOPSIS
Get the frequency distribution of a set.
.DESCRIPTION
This function will get the frequency distribution of a set (array) of data.
It supports array types, as well as strings.
.EXAMPLE
Measure-Frequency $array
.EXAMPLE