Skip to content

Commit

Permalink
Fixed accuracy with encoding and removing newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseALermaIII committed May 21, 2022
1 parent 1acf7b2 commit c51c7f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/modules/Write-RandomText/Write-RandomText.psm1
Expand Up @@ -10,7 +10,7 @@ Generates a pseudo-random dummy text file of given size.
.DESCRIPTION
Generates dummy text file of a given size with the given filename.
Uses System.Web.Security.Membership.GeneratePassword method to make 256 byte
Uses System.Web.Security.Membership.GeneratePassword method to make 128 byte
lines. Multiplying the desired filesize in MiB by 1024*1024, then dividing
by the number of bytes per line produces the number of iterations for a MiB.
Expand Down Expand Up @@ -53,14 +53,14 @@ Date: May 07, 2022
[string]$Filename='RandTextOut.txt'
)
$Filesize *= 1024 * 1024
$Count = $Filesize / 256
$Count = $Filesize / 128
Write-Verbose -Message "Iterations for ${Filesize}: $Count"

$Output = for ($i=1; $i -le $Count; $i++) {
[System.Web.Security.Membership]::GeneratePassword(125, 0)
[System.Web.Security.Membership]::GeneratePassword(128, 0)
}
$CharCount=$Output.Length
Write-Verbose -Message "Output to file: $CharCount"
Out-File -FilePath .\$Filename -InputObject $Output
Out-File -NoNewline -Encoding ASCII -FilePath .\$Filename -InputObject $Output
return
}

0 comments on commit c51c7f3

Please sign in to comment.