Skip to content

Commit

Permalink
Merge pull request #5 from mkropat/dotnet-core
Browse files Browse the repository at this point in the history
Support .NET Core
  • Loading branch information
mkropat authored Mar 4, 2017
2 parents f289db6 + f536869 commit 72d8043
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 283 deletions.
12 changes: 7 additions & 5 deletions Generate-TrigramStatistics.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
function Main {
Add-Type -Path (Join-Path (Get-ScriptDirectory) .\MlkPwgen.FrequencyCounter\bin\Release\MlkPwgen.FrequencyCounter.dll)
$dllPath = Get-ChildItem -Recurse -Include 'MlkPwgen.FrequencyCounter.dll' | Select-Object -First 1 -ExpandProperty FullName
Add-Type -Path $dllPath

$wordlist = Get-Wordlist http://www.freescrabbledictionary.com/english-word-list/download/english.txt
$wordlist = Resolve-Path (Get-Wordlist http://www.freescrabbledictionary.com/english-word-list/download/english.txt)
$statsOutput = Join-Path $PWD '.\MlkPwgen\TrigramStatistics.json.gz'

[MlkPwgen.FrequencyCounter.TrigramFrequencyCounter]::Count($wordlist, '.\MlkPwgen\TrigramStatistics.json.gz')
[MlkPwgen.FrequencyCounter.TrigramFrequencyCounter]::Count($wordlist, $statsOutput)
}

function Get-Wordlist {
param(
[uri] $url
)

$filename = $url.Segments[-1]
if (-not (Test-Path $filename)) {
Invoke-WebRequest $url -OutFile $filename
Expand All @@ -22,4 +24,4 @@ function Get-ScriptDirectory {
Split-Path $script:MyInvocation.MyCommand.Path
}

Main
Main
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Michael Kropat
Copyright (c) 2017 Michael Kropat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
67 changes: 8 additions & 59 deletions MlkPwgen.FrequencyCounter/MlkPwgen.FrequencyCounter.csproj
Original file line number Diff line number Diff line change
@@ -1,66 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5D770642-8B48-406D-B663-C4B8F96574FB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MlkPwgen.FrequencyCounter</RootNamespace>
<AssemblyName>MlkPwgen.FrequencyCounter</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<TargetFrameworks>net45;netstandard1.4</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\MlkPwgen\MlkPwgen.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
<DocumentationFile>bin\Debug\MlkPwgen.FrequencyCounter.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>

<ItemGroup>
<Compile Include="TrigramFrequencySerializer.cs" />
<Compile Include="TrigramFrequencyCounter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<PackageReference Include="System.Runtime.Serialization.Json" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MlkPwgen\MlkPwgen.csproj">
<Project>{545c3ffa-7a76-4acc-99e0-18460552725c}</Project>
<Name>MlkPwgen</Name>
</ProjectReference>
<ProjectReference Include="..\MlkPwgen\MlkPwgen.csproj" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
36 changes: 0 additions & 36 deletions MlkPwgen.FrequencyCounter/Properties/AssemblyInfo.cs

This file was deleted.

44 changes: 32 additions & 12 deletions MlkPwgen.sln
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
# Visual Studio 15
VisualStudioVersion = 15.0.26206.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MlkPwgen", "MlkPwgen\MlkPwgen.csproj", "{545C3FFA-7A76-4ACC-99E0-18460552725C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MlkPwgen", "MlkPwgen\MlkPwgen.csproj", "{4A4887B4-B686-4A28-A767-0F426BF3FE9A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MlkPwgen.FrequencyCounter", "MlkPwgen.FrequencyCounter\MlkPwgen.FrequencyCounter.csproj", "{5D770642-8B48-406D-B663-C4B8F96574FB}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MlkPwgen.FrequencyCounter", "MlkPwgen.FrequencyCounter\MlkPwgen.FrequencyCounter.csproj", "{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{545C3FFA-7A76-4ACC-99E0-18460552725C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{545C3FFA-7A76-4ACC-99E0-18460552725C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{545C3FFA-7A76-4ACC-99E0-18460552725C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{545C3FFA-7A76-4ACC-99E0-18460552725C}.Release|Any CPU.Build.0 = Release|Any CPU
{5D770642-8B48-406D-B663-C4B8F96574FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D770642-8B48-406D-B663-C4B8F96574FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D770642-8B48-406D-B663-C4B8F96574FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D770642-8B48-406D-B663-C4B8F96574FB}.Release|Any CPU.Build.0 = Release|Any CPU
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Debug|x64.ActiveCfg = Debug|x64
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Debug|x64.Build.0 = Debug|x64
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Debug|x86.ActiveCfg = Debug|x86
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Debug|x86.Build.0 = Debug|x86
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Release|Any CPU.Build.0 = Release|Any CPU
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Release|x64.ActiveCfg = Release|x64
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Release|x64.Build.0 = Release|x64
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Release|x86.ActiveCfg = Release|x86
{4A4887B4-B686-4A28-A767-0F426BF3FE9A}.Release|x86.Build.0 = Release|x86
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Debug|x64.ActiveCfg = Debug|x64
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Debug|x64.Build.0 = Debug|x64
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Debug|x86.ActiveCfg = Debug|x86
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Debug|x86.Build.0 = Debug|x86
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Release|Any CPU.Build.0 = Release|Any CPU
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Release|x64.ActiveCfg = Release|x64
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Release|x64.Build.0 = Release|x64
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Release|x86.ActiveCfg = Release|x86
{E524079D-89EA-4070-BD43-D6B6F0B6EDC9}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions MlkPwgen/CryptoServiceRandom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
namespace MlkPwgen
{
/// <summary>
/// Implementation of <see cref="Random"/> that wraps <see cref="RNGCryptoServiceProvider"/>
/// Implementation of <see cref="Random"/> that wraps <see cref="RandomNumberGenerator"/>
/// </summary>
public sealed class CryptoServiceRandom : Random, IDisposable
{
byte[] _buf = new byte[sizeof(uint) * 64];
int _i;
readonly RandomNumberGenerator _rng;

public CryptoServiceRandom() : this(new RNGCryptoServiceProvider()) { }
public CryptoServiceRandom() : this(RandomNumberGenerator.Create()) { }

public CryptoServiceRandom(RandomNumberGenerator rng)
{
Expand Down
3 changes: 2 additions & 1 deletion MlkPwgen/EmbeddedTrigramStatistics.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.Serialization.Json;

namespace MlkPwgen
Expand Down Expand Up @@ -43,7 +44,7 @@ public IReadOnlyCollection<WeightedItem<char>> GetTrigramWeights(Tuple<char, cha

SerializableTrigramStatistics LoadStats()
{
var asm = typeof(EmbeddedTrigramStatistics).Assembly;
var asm = typeof(EmbeddedTrigramStatistics).GetTypeInfo().Assembly;
using (var rscStream = asm.GetManifestResourceStream("MlkPwgen.TrigramStatistics.json.gz"))
using (var zipStream = new GZipStream(rscStream, CompressionMode.Decompress))
{
Expand Down
110 changes: 37 additions & 73 deletions MlkPwgen/MlkPwgen.csproj
Original file line number Diff line number Diff line change
@@ -1,84 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{545C3FFA-7A76-4ACC-99E0-18460552725C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MlkPwgen</RootNamespace>
<AssemblyName>MlkPwgen</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<Authors>Michael Kropat</Authors>
<Copyright>Copyright 2017</Copyright>
<Description>Secure random password generator.
Uses a cryptographically secure PRNG
Can guarantee that the password contains digits, special characters, or any other set
Can generate pronounceable, easier-to-remember passwords
Packaged as a .NET library and as a PowerShell module
API Documentation available at the project site</Description>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PackageId>MlkPwgen</PackageId>
<PackageLicenseUrl>https://github.com/mkropat/MlkPwgen/blob/master/LICENSE.txt</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/mkropat/MlkPwgen</PackageProjectUrl>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>random password generator pronounceable</PackageTags>
<PackageVersion>0.3.0</PackageVersion>
<Summary>Secure random password generator</Summary>
<TargetFrameworks>net45;netstandard1.4</TargetFrameworks>
<Title>MlkPwgen</Title>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>MlkPwgen.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\Debug\MlkPwgen.XML</DocumentationFile>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net45|AnyCPU'">
<DocumentationFile>bin\Release\net45\MlkPwgen.xml</DocumentationFile>
<NoWarn>1591;1701;1702;1705</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>MlkPwgen.ruleset</CodeAnalysisRuleSet>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard1.4|AnyCPU'">
<DocumentationFile>bin\Release\netstandard1.4\MlkPwgen.xml</DocumentationFile>
<NoWarn>1591;1701;1702;1705</NoWarn>
</PropertyGroup>

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Sets.cs" />
<Compile Include="CryptoServiceRandom.cs" />
<Compile Include="EmbeddedTrigramStatistics.cs" />
<Compile Include="ITrigramStatistics.cs" />
<Compile Include="PasswordGenerator.cs" />
<Compile Include="PronounceableGenerator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Random.cs" />
<Compile Include="SerializableTrigramStatistics.cs" />
<Compile Include="WeightedItem.cs" />
<None Remove="TrigramStatistics.json.gz" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="TrigramStatistics.json.gz" />
</ItemGroup>
<ItemGroup>
<None Include="MlkPwgen.nuspec" />
<None Include="MlkPwgen.ruleset" />

<ItemGroup Condition="'$(TargetFramework)'=='netstandard1.4'">
<PackageReference Include="System.Runtime.Serialization.Json" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
<ItemGroup>
<ModuleFiles Include="$(ProjectDir)\..\Powershell\*.*" />
</ItemGroup>
<Exec Command="nuget pack MlkPwgen.csproj -Prop Configuration=Release"></Exec>
<Copy SourceFiles="@(ModuleFiles)" DestinationFolder="$(OutputPath)" />
</Target>

</Project>
25 changes: 0 additions & 25 deletions MlkPwgen/MlkPwgen.nuspec

This file was deleted.

Loading

0 comments on commit 72d8043

Please # to comment.