added Password Generator

This commit is contained in:
WeeXnes 2023-06-08 21:40:04 +02:00
parent 826e6823a1
commit 2f4ac2f00d
16 changed files with 221 additions and 256 deletions

View file

@ -1,134 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
namespace Release_Tool
{
internal class Program
{
static List<file> files = new List<file>();
public static string globalTimestamp = null;
public static string releaseFolder = "debug_release";
public static string releaseFileName = "currentRelease";
public static string fileending = ".zip";
public static string destFolder = null;
public static bool success = true;
public static bool Contains(string source, string toCheck, StringComparison comp)
{
return source?.IndexOf(toCheck, comp) >= 0;
}
public static void Main(string[] args)
{
var lines = File.ReadAllLines(".\\WeeXnes\\Core\\Globals.cs");
string versionLine = "";
foreach (var line in lines)
{
if (Contains(line, "public static string version", StringComparison.OrdinalIgnoreCase))
{
versionLine = line;
}
}
Console.WriteLine(versionLine);
string versionnr =
versionLine.Substring(versionLine.IndexOf("\""), versionLine.Length - versionLine.IndexOf("\""));
versionnr = versionnr.Substring(1, versionnr.Length - 1);
versionnr = versionnr.Substring(0, versionnr.IndexOf("\""));
string VersionNumber = versionnr;
releaseFileName = releaseFileName + "_" + versionnr + fileending;
Console.WriteLine("Packing " + releaseFileName);
Console.Title = "WeeXnes Automated Release Tool";
SetTimestamp();
SetPaths();
Console.WriteLine("Folder -> " + globalTimestamp);
CheckDirectories();
GetFiles();
PackFiles();
if (!success)
{
Console.WriteLine("Something went wrong");
Console.ReadLine();
}
else
{
PackIntoZip();
Console.WriteLine("Build succeeded | " + globalTimestamp);
Console.ReadLine();
}
}
private static void PackIntoZip()
{
try
{
if(File.Exists(Path.Combine(releaseFolder, releaseFileName)))
{
File.Delete(Path.Combine(releaseFolder, "currentRelease.zip"));
ZipFile.CreateFromDirectory(destFolder, Path.Combine(releaseFolder, releaseFileName));
}
else
{
ZipFile.CreateFromDirectory(destFolder, Path.Combine(releaseFolder, releaseFileName));
}
}catch (Exception ex)
{
Console.WriteLine(ex);
Console.ReadLine();
}
}
private static void SetPaths()
{
destFolder = Path.Combine(releaseFolder, globalTimestamp);
}
private static void CheckDirectories()
{
if (!Directory.Exists(releaseFolder))
{
Directory.CreateDirectory(releaseFolder);
}
if(!Directory.Exists(destFolder))
{
Directory.CreateDirectory(destFolder);
}
}
private static void SetTimestamp()
{
string date = DateTime.Now.ToString("dd.MM.yyyy");
string time = DateTime.Now.ToString("HH.mm.ss");
string timestamp = date + " - " + time;
globalTimestamp = timestamp;
}
private static void PackFiles()
{
foreach(file fileobj in files)
{
try
{
File.Copy(fileobj.path, Path.Combine(destFolder, fileobj.newfilename));
Console.WriteLine("Copied " + fileobj.path);
}
catch (Exception ex)
{
Console.WriteLine("Coudnt find " + fileobj.path + "| ->" + ex.GetType());
success = false;
}
}
}
private static void GetFiles()
{
files.Add(new file(@"WeeXnes\bin\Release\WeeXnes.exe", "WeeXnes.exe"));
files.Add(new file(@"WeeXnes_UAC\bin\Release\WeeXnes_UAC.exe", "WeeXnes_UAC.exe"));
files.Add(new file(@"WeeXnes\bin\Release\DiscordRPC.dll", "DiscordRPC.dll"));
files.Add(new file(@"WeeXnes\bin\Release\Newtonsoft.Json.dll", "Newtonsoft.Json.dll"));
files.Add(new file(@"Autostart\bin\Release\Autostart.exe", "Autostart.exe"));
files.Add(new file(@"Update\bin\Release\Update.exe", "Update.exe"));
}
}
}

View file

@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Release_Tool")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Release_Tool")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4C09AD12-B48E-40ED-B418-CF868889E317")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4C09AD12-B48E-40ED-B418-CF868889E317}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Release_Tool</RootNamespace>
<AssemblyName>Release_Tool</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<ApplicationIcon>wicns.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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.Data" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="file.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="wicns.ico" />
</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>

View file

@ -1,13 +0,0 @@
namespace Release_Tool
{
public class file
{
public string path { get; set; }
public string newfilename { get; set; }
public file(string _path, string _newfilename)
{
this.path = _path;
this.newfilename = _newfilename;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 KiB

View file

@ -6,8 +6,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autostart", "Autostart\Auto
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeeXnes_UAC", "WeeXnes_UAC\WeeXnes_UAC.csproj", "{2DCC0DCD-7843-4719-9FDD-1786924CF941}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Release_Tool", "Release_Tool\Release_Tool.csproj", "{4C09AD12-B48E-40ED-B418-CF868889E317}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Update", "Update\Update.csproj", "{133FF515-D605-4856-BA2E-5841BF47EC2F}"
EndProject
Global
@ -28,10 +26,6 @@ Global
{2DCC0DCD-7843-4719-9FDD-1786924CF941}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DCC0DCD-7843-4719-9FDD-1786924CF941}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DCC0DCD-7843-4719-9FDD-1786924CF941}.Release|Any CPU.Build.0 = Release|Any CPU
{4C09AD12-B48E-40ED-B418-CF868889E317}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C09AD12-B48E-40ED-B418-CF868889E317}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C09AD12-B48E-40ED-B418-CF868889E317}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C09AD12-B48E-40ED-B418-CF868889E317}.Release|Any CPU.Build.0 = Release|Any CPU
{133FF515-D605-4856-BA2E-5841BF47EC2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{133FF515-D605-4856-BA2E-5841BF47EC2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{133FF515-D605-4856-BA2E-5841BF47EC2F}.Release|Any CPU.ActiveCfg = Release|Any CPU

View file

@ -148,7 +148,7 @@ namespace WeeXnes
);
newItem.Filename = file.Name;
KeyManagerView.Data.KeyItemsList.Add(newItem);
WeeXnes.Core.CustomConsole.WriteLineVerbose(file.Name + " loaded");
WeeXnes.Core.CustomConsole.WriteLine(file.Name + " loaded");
}
catch (Exception ex)

View file

@ -8,7 +8,7 @@ namespace WeeXnes.Core
{
public class Information
{
public const string Version = "4.3.5";
public const string Version = "4.4.0";
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
}

View file

@ -8,6 +8,7 @@
xmlns:keymanager="clr-namespace:WeeXnes.Views.KeyManager"
xmlns:settings="clr-namespace:WeeXnes.Views.Settings"
xmlns:discordrpc="clr-namespace:WeeXnes.Views.DiscordRPC"
xmlns:passwordGenerator="clr-namespace:WeeXnes.Views.PasswordGenerator"
mc:Ignorable="d"
Height="400"
Width="500"
@ -68,11 +69,6 @@
PageTag="home"
Name="ButtonHome"
PageType="{x:Type home:HomeView}"/>
<ui:NavigationItem
Content="Keys"
Icon="Key24"
PageTag="Keys"
PageType="{x:Type keymanager:KeyManagerView}"/>
<ui:NavigationItem
Content="RPC"
Icon="XboxController24"
@ -80,6 +76,17 @@
PageTag="RPC"
PageType="{x:Type discordrpc:DiscordRPCView}"
Loaded="RPCBtn_OnLoaded"/>
<ui:NavigationItem
Content="Keys"
Icon="Key24"
PageTag="Keys"
PageType="{x:Type keymanager:KeyManagerView}"/>
<ui:NavigationItem
Content="Gen."
Icon="Password24"
Name="ButtonPwGen"
PageTag="Gen"
PageType="{x:Type passwordGenerator:PasswordGenView}"/>
</ui:NavigationStore.Items>
<ui:NavigationStore.Footer>
<ui:NavigationItem

View file

@ -0,0 +1,22 @@
<Page x:Class="WeeXnes.Views.PasswordGenerator.PasswordGenView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WeeXnes.Views.PasswordGenerator"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
Title="PasswordGenView" Height="Auto" Width="Auto">
<Grid>
<StackPanel Orientation="Vertical">
<Label Foreground="White" Content="Password Generator" HorizontalAlignment="Center"/>
<Label Content="Lenght: " Foreground="White"/>
<ui:NumberBox Name="numbox_pwCount" Margin="0,5" DecimalPlaces="0" Min="1" Value="15"/>
<ui:ToggleSwitch Name="toggle_alpha" Margin="0,5" Content="a-z" IsChecked="True"/>
<ui:ToggleSwitch Name="toggle_numeric" Margin="0,5" Content="0-9" IsChecked="True"/>
<ui:ToggleSwitch Name="toggle_caps" Margin="0,5" Content="Capitalization" IsChecked="True"/>
<ui:ToggleSwitch Name="toggle_special" Margin="0,5" Content="Special characters"/>
<ui:Button Content="Generate Password" HorizontalAlignment="Stretch" Click="ButtonBase_OnClick"/>
</StackPanel>
</Grid>
</Page>

View file

@ -0,0 +1,67 @@
using System;
using System.Windows;
using System.Windows.Controls;
using WeeXnes.Core;
namespace WeeXnes.Views.PasswordGenerator
{
public partial class PasswordGenView : Page
{
public static Random random = new Random();
private class PasswordBuilderStrings
{
public static string alphabetical_lc = "abcdefghijklmnopqrstuvwxyz";
public static string alphabetical_caps = "ABCDEFGHIJKLMNOPQRSTUVQXYZ";
public static string numerical = "1234567890";
public static string special = "!#$%&()*+,-<>=?";
}
public PasswordGenView()
{
InitializeComponent();
}
private void GeneratePasword()
{
if(toggle_alpha.IsChecked == false)
if(toggle_numeric.IsChecked == false)
if(toggle_special.IsChecked == false)
return;
string CustomPasswordBuilderString = "";
if (toggle_alpha.IsChecked == true)
CustomPasswordBuilderString += PasswordBuilderStrings.alphabetical_lc;
if (toggle_caps.IsChecked == true)
CustomPasswordBuilderString += PasswordBuilderStrings.alphabetical_caps;
if (toggle_numeric.IsChecked == true)
CustomPasswordBuilderString += PasswordBuilderStrings.numerical;
if (toggle_special.IsChecked == true)
CustomPasswordBuilderString += PasswordBuilderStrings.special;
CustomConsole.WriteLine("Generating Password from: " + CustomPasswordBuilderString);
//MessageBox.Show(CustomPasswordBuilderString);
string generatedPassword = "";
for (int i = 0; i < numbox_pwCount.Value; i++)
{
int randomNr = random.Next(0, CustomPasswordBuilderString.Length);
generatedPassword = generatedPassword + CustomPasswordBuilderString[randomNr];
}
SavePasswordView.GeneratedPassword = generatedPassword;
NavigationService.Navigate(new Uri("/Views/PasswordGenerator/SavePasswordView.xaml",UriKind.Relative));
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
GeneratePasword();
}
}
}

View file

@ -0,0 +1,20 @@
<Page x:Class="WeeXnes.Views.PasswordGenerator.SavePasswordView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WeeXnes.Views.PasswordGenerator"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
Title="SavePasswordView" Height="Auto" Width="Auto"
Loaded="SavePasswordView_OnLoaded">
<Grid>
<StackPanel Orientation="Vertical">
<Label Content="Password Generated: " Foreground="White" FontSize="20"/>
<Label Name="displayPassword" Foreground="White" FontSize="15" Margin="0,0,0,5"/>
<ui:Button Content="Copy to clipboard" HorizontalAlignment="Stretch" Click="CopyToClipboard" Margin="0,3"/>
<ui:Button Content="Save to KeyManager" HorizontalAlignment="Stretch" Click="SaveToKeyManager" Margin="0,3"/>
<ui:Button Content="Back" HorizontalAlignment="Stretch" Click="CloseDialog" Margin="0,3"/>
</StackPanel>
</Grid>
</Page>

View file

@ -0,0 +1,33 @@
using System;
using System.Windows;
using System.Windows.Controls;
namespace WeeXnes.Views.PasswordGenerator
{
public partial class SavePasswordView : Page
{
public static string GeneratedPassword = "";
public SavePasswordView()
{
InitializeComponent();
}
private void SavePasswordView_OnLoaded(object sender, RoutedEventArgs e)
{
displayPassword.Content = GeneratedPassword;
}
private void CloseDialog(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Views/PasswordGenerator/PasswordGenView.xaml",UriKind.Relative));
}
private void CopyToClipboard(object sender, RoutedEventArgs e)
{
Clipboard.SetText(GeneratedPassword);
}
private void SaveToKeyManager(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Views/PasswordGenerator/SaveToKeyManagerView.xaml",UriKind.Relative));
}
}
}

View file

@ -0,0 +1,17 @@
<Page x:Class="WeeXnes.Views.PasswordGenerator.SaveToKeyManagerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WeeXnes.Views.PasswordGenerator"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
Title="SaveToKeyManagerView" Height="Auto" Width="Auto">
<Grid>
<StackPanel Orientation="Vertical">
<Label Content="Save password to KeyManager: " Foreground="White" FontSize="20"/>
<ui:TextBox PlaceholderText="Name for Password" Name="tb_keyname"/>
<ui:Button Content="Save" HorizontalAlignment="Stretch" Click="SavePassword" Margin="0,3"/>
</StackPanel>
</Grid>
</Page>

View file

@ -0,0 +1,35 @@
using System;
using System.Windows;
using System.Windows.Controls;
using WeeXnes.Core;
using WeeXnes.Views.KeyManager;
namespace WeeXnes.Views.PasswordGenerator
{
public partial class SaveToKeyManagerView : Page
{
public SaveToKeyManagerView()
{
InitializeComponent();
}
private void SavePassword(object sender, RoutedEventArgs e)
{
try
{
KeyItem newKey = new KeyItem(
tb_keyname.Text,
SavePasswordView.GeneratedPassword
);
WXFile wxFile = new WXFile(
Global.AppDataPathKEY.Value + "\\" + newKey.Filename);
WXFile.Methods.WriteFile(newKey, wxFile);
KeyManagerView.Data.KeyItemsList.Add(newKey);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
NavigationService.Navigate(new Uri("/Views/PasswordGenerator/PasswordGenView.xaml",UriKind.Relative));
}
}
}

View file

@ -4,7 +4,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Version>4.3.5</Version>
<Version>4.4.0</Version>
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WeeXnes</RootNamespace>
@ -94,6 +94,15 @@
<Compile Include="Views\KeyManager\KeyManagerView.xaml.cs">
<DependentUpon>KeyManagerView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PasswordGenerator\PasswordGenView.xaml.cs">
<DependentUpon>PasswordGenView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PasswordGenerator\SavePasswordView.xaml.cs">
<DependentUpon>SavePasswordView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PasswordGenerator\SaveToKeyManagerView.xaml.cs">
<DependentUpon>SaveToKeyManagerView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Settings\ApiResponse.cs" />
<Compile Include="Views\Settings\ChangePathsView.xaml.cs">
<DependentUpon>ChangePathsView.xaml</DependentUpon>
@ -129,6 +138,9 @@
<Page Include="Views\DiscordRPC\RunRPCView.xaml" />
<Page Include="Views\Home\HomeView.xaml" />
<Page Include="Views\KeyManager\KeyManagerView.xaml" />
<Page Include="Views\PasswordGenerator\PasswordGenView.xaml" />
<Page Include="Views\PasswordGenerator\SavePasswordView.xaml" />
<Page Include="Views\PasswordGenerator\SaveToKeyManagerView.xaml" />
<Page Include="Views\Settings\ChangePathsView.xaml" />
<Page Include="Views\Settings\FluentMessageBox.xaml" />
<Page Include="Views\Settings\SettingsView.xaml" />