MS Encryption
This commit is contained in:
parent
55f2a6a775
commit
d4aa3ec82e
@ -156,10 +156,12 @@
|
|||||||
<Compile Include="frmSplashScreen.vb">
|
<Compile Include="frmSplashScreen.vb">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Helper\Encryption.vb" />
|
||||||
<Compile Include="Helper\RefreshHelper.vb" />
|
<Compile Include="Helper\RefreshHelper.vb" />
|
||||||
<Compile Include="Helper\TempFiles.vb" />
|
<Compile Include="Helper\TempFiles.vb" />
|
||||||
<Compile Include="Helper\Thumbnail.vb" />
|
<Compile Include="Helper\Thumbnail.vb" />
|
||||||
<Compile Include="Helper\Validator.vb" />
|
<Compile Include="Helper\Validator.vb" />
|
||||||
|
<Compile Include="ModuleSettings.vb" />
|
||||||
<Compile Include="My Project\Application.Designer.vb">
|
<Compile Include="My Project\Application.Designer.vb">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DependentUpon>Application.myapp</DependentUpon>
|
<DependentUpon>Application.myapp</DependentUpon>
|
||||||
|
|||||||
24
EnvelopeGenerator.Form/Helper/Encryption.vb
Normal file
24
EnvelopeGenerator.Form/Helper/Encryption.vb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
Imports System.Security.Cryptography
|
||||||
|
Imports System.Text
|
||||||
|
|
||||||
|
Public Class Decryption
|
||||||
|
|
||||||
|
Private Shared key As String = "$xzBvyPETUS&amm8)D8x#)f;4%;?[BPd" ' Passwort-Schlüssel (16, 24, or 32 bytes)
|
||||||
|
Private Shared iv As String = "1wN&e[zrQ6_B7X/0" ' Initialisierungsvektor (16 bytes)
|
||||||
|
|
||||||
|
|
||||||
|
' Entschlüsselungsfunktion
|
||||||
|
Public Shared Function Decrypt(cipherText As String) As String
|
||||||
|
Dim aesAlg As Aes = Aes.Create()
|
||||||
|
aesAlg.Key = Encoding.UTF8.GetBytes(key)
|
||||||
|
aesAlg.IV = Encoding.UTF8.GetBytes(iv)
|
||||||
|
Dim decryptor As ICryptoTransform = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV)
|
||||||
|
Dim cipherBytes As Byte() = Convert.FromBase64String(cipherText)
|
||||||
|
Dim msDecrypt As New IO.MemoryStream(cipherBytes)
|
||||||
|
Using csDecrypt As New CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)
|
||||||
|
Using srDecrypt As New IO.StreamReader(csDecrypt)
|
||||||
|
Return srDecrypt.ReadToEnd()
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
3
EnvelopeGenerator.Form/ModuleSettings.vb
Normal file
3
EnvelopeGenerator.Form/ModuleSettings.vb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Module ModuleSettings
|
||||||
|
Public DOCUMENT_PATH_MOVE_AFTSEND As String = ""
|
||||||
|
End Module
|
||||||
@ -1,26 +1,89 @@
|
|||||||
'------------------------------------------------------------------------------
|
'------------------------------------------------------------------------------
|
||||||
' <auto-generated>
|
' <auto-generated>
|
||||||
' This code was generated by a tool.
|
' Dieser Code wurde von einem Tool generiert.
|
||||||
' Runtime Version:4.0.30319.18034
|
' Laufzeitversion:4.0.30319.42000
|
||||||
'
|
'
|
||||||
' Changes to this file may cause incorrect behavior and will be lost if
|
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||||
' the code is regenerated.
|
' der Code erneut generiert wird.
|
||||||
' </auto-generated>
|
' </auto-generated>
|
||||||
'------------------------------------------------------------------------------
|
'------------------------------------------------------------------------------
|
||||||
|
|
||||||
Namespace My
|
Option Strict On
|
||||||
|
Option Explicit On
|
||||||
|
|
||||||
|
|
||||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")>
|
|
||||||
Friend NotInheritable Partial Class Settings
|
|
||||||
Inherits System.Configuration.ApplicationSettingsBase
|
|
||||||
|
|
||||||
Private Shared defaultInstance As Settings = (CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New Settings()), Settings))
|
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||||
|
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0"), _
|
||||||
|
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||||
|
Partial Friend NotInheritable Class Settings
|
||||||
|
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||||
|
|
||||||
|
Private Shared defaultInstance As Settings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New Settings()),Settings)
|
||||||
|
|
||||||
|
#Region "Automatische My.Settings-Speicherfunktion"
|
||||||
|
#If _MyType = "WindowsForms" Then
|
||||||
|
Private Shared addedHandler As Boolean
|
||||||
|
|
||||||
|
Private Shared addedHandlerLockObject As New Object
|
||||||
|
|
||||||
|
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||||
|
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
|
||||||
|
If My.Application.SaveMySettingsOnExit Then
|
||||||
|
My.Settings.Save()
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
#End If
|
||||||
|
#End Region
|
||||||
|
|
||||||
Public Shared ReadOnly Property [Default]() As Settings
|
Public Shared ReadOnly Property [Default]() As Settings
|
||||||
Get
|
Get
|
||||||
|
|
||||||
|
#If _MyType = "WindowsForms" Then
|
||||||
|
If Not addedHandler Then
|
||||||
|
SyncLock addedHandlerLockObject
|
||||||
|
If Not addedHandler Then
|
||||||
|
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||||
|
addedHandler = True
|
||||||
|
End If
|
||||||
|
End SyncLock
|
||||||
|
End If
|
||||||
|
#End If
|
||||||
Return defaultInstance
|
Return defaultInstance
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||||
|
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||||
|
Global.System.Configuration.DefaultSettingValueAttribute("dd-san01\Administrator")> _
|
||||||
|
Public ReadOnly Property NetUse_Usr() As String
|
||||||
|
Get
|
||||||
|
Return CType(Me("NetUse_Usr"),String)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||||
|
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||||
|
Global.System.Configuration.DefaultSettingValueAttribute("sY4vnATDXwosbTJGip6SqA==")> _
|
||||||
|
Public ReadOnly Property NetUse_PW() As String
|
||||||
|
Get
|
||||||
|
Return CType(Me("NetUse_PW"),String)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
Namespace My
|
||||||
|
|
||||||
|
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||||
|
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||||
|
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||||
|
Friend Module MySettingsProperty
|
||||||
|
|
||||||
|
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||||
|
Friend ReadOnly Property Settings() As Global.EnvelopeGenerator.Form.Settings
|
||||||
|
Get
|
||||||
|
Return Global.EnvelopeGenerator.Form.Settings.Default
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
End Module
|
||||||
End Namespace
|
End Namespace
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="" GeneratedClassName="Settings">
|
||||||
<Profiles>
|
<Profiles />
|
||||||
<Profile Name="(Default)" />
|
<Settings>
|
||||||
</Profiles>
|
<Setting Name="NetUse_Usr" Type="System.String" Scope="Application">
|
||||||
<Settings />
|
<Value Profile="(Default)">dd-san01\Administrator</Value>
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="NetUse_PW" Type="System.String" Scope="Application">
|
||||||
|
<Value Profile="(Default)">sY4vnATDXwosbTJGip6SqA==</Value>
|
||||||
|
</Setting>
|
||||||
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
@ -2,10 +2,19 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
<configSections>
|
||||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System">
|
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System">
|
||||||
|
<section name="EnvelopeGenerator.Form.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
<section name="DevExpress.LookAndFeel.Design.AppSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
<section name="DevExpress.LookAndFeel.Design.AppSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
</configSections>
|
</configSections>
|
||||||
<applicationSettings>
|
<applicationSettings>
|
||||||
|
<EnvelopeGenerator.Form.Settings>
|
||||||
|
<setting name="NetUse_Usr" serializeAs="String">
|
||||||
|
<value>dd-san01\Administrator</value>
|
||||||
|
</setting>
|
||||||
|
<setting name="NetUse_PW" serializeAs="String">
|
||||||
|
<value>sY4vnATDXwosbTJGip6SqA==</value>
|
||||||
|
</setting>
|
||||||
|
</EnvelopeGenerator.Form.Settings>
|
||||||
<DevExpress.LookAndFeel.Design.AppSettings>
|
<DevExpress.LookAndFeel.Design.AppSettings>
|
||||||
<setting name="DPIAwarenessMode" serializeAs="String">
|
<setting name="DPIAwarenessMode" serializeAs="String">
|
||||||
<value>System</value>
|
<value>System</value>
|
||||||
|
|||||||
@ -21,7 +21,6 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
|
|
||||||
Private Controller As EnvelopeEditorController
|
Private Controller As EnvelopeEditorController
|
||||||
Private Logger As Logger
|
Private Logger As Logger
|
||||||
Private Config As DbConfig
|
|
||||||
|
|
||||||
Private Const COL_NAME = "Name"
|
Private Const COL_NAME = "Name"
|
||||||
Private Const COL_EMAIL = "Email"
|
Private Const COL_EMAIL = "Email"
|
||||||
@ -64,7 +63,7 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
|
|
||||||
Private Sub frmEditor_Load(sender As Object, e As EventArgs) Handles Me.Load
|
Private Sub frmEditor_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||||
Logger = State.LogConfig.GetLogger()
|
Logger = State.LogConfig.GetLogger()
|
||||||
|
Logger.Debug("Loading Configuration..")
|
||||||
If Envelope Is Nothing Then
|
If Envelope Is Nothing Then
|
||||||
Controller = New EnvelopeEditorController(State)
|
Controller = New EnvelopeEditorController(State)
|
||||||
|
|
||||||
@ -330,16 +329,50 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
MsgBox(Resources.Envelope.Envelope_could_not_be_sent, MsgBoxStyle.Critical, Text)
|
MsgBox(Resources.Envelope.Envelope_could_not_be_sent, MsgBoxStyle.Critical, Text)
|
||||||
Else
|
Else
|
||||||
If MsgBox(Resources.Envelope.Envelope_Invitations_Sent, MsgBoxStyle.Information Or MsgBoxStyle.OkOnly, Text) = MsgBoxResult.Ok Then
|
If MsgBox(Resources.Envelope.Envelope_Invitations_Sent, MsgBoxStyle.Information Or MsgBoxStyle.OkOnly, Text) = MsgBoxResult.Ok Then
|
||||||
If Config.DOCUMENT_PATH_MOVE_AFTSEND <> String.Empty Then
|
If DOCUMENT_PATH_MOVE_AFTSEND <> String.Empty Then
|
||||||
For Each odoc In Envelope.Documents
|
If My.Settings.NetUse_PW <> String.Empty And My.Settings.NetUse_Usr <> String.Empty Then
|
||||||
|
Dim oDecrypted = Decryption.Decrypt(My.Settings.NetUse_PW)
|
||||||
|
For Each odoc In Controller.Envelope.Documents 'envelope ist leer!
|
||||||
|
MoveFileWithNetUse(odoc.Filepath, DOCUMENT_PATH_MOVE_AFTSEND, My.Settings.NetUse_Usr, My.Settings.NetUse_PW)
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
Me.Close()
|
Me.Close()
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Sub MoveFileWithNetUse(pSourcePath As String, pDestinationPath As String, pUsername As String, pPassword As String)
|
||||||
|
Dim oDectryptedPW = Decryption.Decrypt(pPassword)
|
||||||
|
Dim oFilename = System.IO.Path.GetFileName(pSourcePath)
|
||||||
|
|
||||||
|
Dim netUseCommand As String = $"net use {pDestinationPath} /user:{pUsername} {oDectryptedPW}"
|
||||||
|
|
||||||
|
Dim processInfo As New ProcessStartInfo("cmd.exe", $"/C {netUseCommand}")
|
||||||
|
processInfo.RedirectStandardOutput = True
|
||||||
|
processInfo.UseShellExecute = False
|
||||||
|
processInfo.CreateNoWindow = True
|
||||||
|
|
||||||
|
Using process As Process = Process.Start(processInfo)
|
||||||
|
process.WaitForExit()
|
||||||
|
|
||||||
|
' Prüfe den Rückgabewert des net use Befehls
|
||||||
|
If process.ExitCode = 0 Then
|
||||||
|
' Verschiebe die Datei
|
||||||
|
Try
|
||||||
|
pDestinationPath &= "\" + oFilename
|
||||||
|
System.IO.File.Copy(pSourcePath, pDestinationPath, True)
|
||||||
|
Catch ex As Exception
|
||||||
|
MsgBox(ex.Message, MsgBoxStyle.Critical)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Else
|
||||||
|
MsgBox("Fehler beim Verbinden mit dem Netzwerkziel.", MsgBoxStyle.Critical)
|
||||||
|
End If
|
||||||
|
End Using
|
||||||
|
End Sub
|
||||||
Private Sub btnCancel_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnCancel.ItemClick
|
Private Sub btnCancel_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnCancel.ItemClick
|
||||||
' Speichern?
|
' Speichern?
|
||||||
Dim oMessage = Resources.Envelope.Should_The_Envelope_Be_Saved
|
Dim oMessage = Resources.Envelope.Should_The_Envelope_Be_Saved
|
||||||
|
|||||||
@ -77,7 +77,7 @@ Public Class frmSplashScreen
|
|||||||
|
|
||||||
Dim ConfigModel = New ConfigModel(oState)
|
Dim ConfigModel = New ConfigModel(oState)
|
||||||
oState.DbConfig = ConfigModel.LoadConfiguration()
|
oState.DbConfig = ConfigModel.LoadConfiguration()
|
||||||
|
DOCUMENT_PATH_MOVE_AFTSEND = oState.DbConfig.DOCUMENT_PATH_MOVE_AFTSEND
|
||||||
Worker.ReportProgress(60, "Initialize User")
|
Worker.ReportProgress(60, "Initialize User")
|
||||||
Thread.Sleep(300)
|
Thread.Sleep(300)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user