mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-11-29 02:50:48 +00:00
Add SEED algorithm test project for WelsonJS.Cryptography
Introduced a new test project 'WelsonJS.Cryptography.Test' with a Program.vb that tests SEED encryption and decryption. Updated the solution file to include both the cryptography library and its test project, and configured build settings for all platforms.
This commit is contained in:
parent
9afb64a997
commit
63f009fb73
56
WelsonJS.Toolkit/WelsonJS.Cryptography.Test/Program.vb
Normal file
56
WelsonJS.Toolkit/WelsonJS.Cryptography.Test/Program.vb
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
' Program.cs (WelsonJS.Cryptography.Test)
|
||||
' SPDX-License-Identifier: MIT
|
||||
' SPDX-FileCopyrightText: 2025 Namhyeon Go <gnh1201@catswords.re.kr>, Catswords OSS And WelsonJS Contributors
|
||||
' https://github.com/gnh1201/welsonjs
|
||||
'
|
||||
Imports System.IO
|
||||
Imports System.Security.Cryptography
|
||||
Imports System.Text
|
||||
|
||||
Module Program
|
||||
Sub Main(args As String())
|
||||
Console.WriteLine("Start SEED encryption and decryption test")
|
||||
Dim cipher As New WelsonJS.Cryptography.SeedAlgorithm()
|
||||
|
||||
cipher.Key = {&H2B, &H7E, &H15, &H16, &H28, &HAE, &HD2, &HA6, &HAB, &HF7, &H15, &H88, &H9, &HCF, &H4F, &H3C}
|
||||
cipher.IV = {&H26, &H8D, &H66, &HA7, &H35, &HA8, &H1A, &H81, &H6F, &HBA, &HD9, &HFA, &H36, &H16, &H25, &H1}
|
||||
cipher.Mode = CipherMode.ECB
|
||||
cipher.Padding = PaddingMode.PKCS7
|
||||
|
||||
RunTest(cipher)
|
||||
End Sub
|
||||
|
||||
Public Sub RunTest(cipher As SymmetricAlgorithm)
|
||||
Dim inputBytes As Byte() = {&H0, &H1, &H2, &H3, &H4, &H5, &H6, &H7, &H8, &H9, &HA, &HB, &HC, &HD, &HE, &HF, &H0, &H1}
|
||||
|
||||
Console.WriteLine("Original bytes (HEX):")
|
||||
PrintHex(inputBytes)
|
||||
|
||||
Dim encryptor As ICryptoTransform = cipher.CreateEncryptor()
|
||||
Dim encrypted As Byte() = ApplyTransform(encryptor, inputBytes)
|
||||
Console.WriteLine("Encrypted (HEX):")
|
||||
PrintHex(encrypted)
|
||||
|
||||
Dim decryptor As ICryptoTransform = cipher.CreateDecryptor()
|
||||
Dim decrypted As Byte() = ApplyTransform(decryptor, encrypted)
|
||||
Console.WriteLine("Decrypted (HEX):")
|
||||
PrintHex(decrypted)
|
||||
End Sub
|
||||
|
||||
Private Function ApplyTransform(transformer As ICryptoTransform, input As Byte()) As Byte()
|
||||
Using ms As New MemoryStream()
|
||||
Using cs As New CryptoStream(ms, transformer, CryptoStreamMode.Write)
|
||||
cs.Write(input, 0, input.Length)
|
||||
cs.FlushFinalBlock()
|
||||
Return ms.ToArray()
|
||||
End Using
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Private Sub PrintHex(data As Byte())
|
||||
For Each b As Byte In data
|
||||
Console.Write("{0:X2} ", b)
|
||||
Next
|
||||
Console.WriteLine()
|
||||
End Sub
|
||||
End Module
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>WelsonJS.Cryptography.Test</RootNamespace>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x86</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WelsonJS.Cryptography\WelsonJS.Cryptography.vbproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -11,7 +11,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WelsonJS.Launcher", "Welson
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EsentInterop", "EsentInterop\EsentInterop.csproj", "{E929E163-52A0-4AAC-917B-6D7FAF70C45E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WelsonJS.Esent", "WelsonJS.Esent\WelsonJS.Esent.csproj", "{783F2DB2-80D0-4F58-A55E-9593E44D5743}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WelsonJS.Esent", "WelsonJS.Esent\WelsonJS.Esent.csproj", "{783F2DB2-80D0-4F58-A55E-9593E44D5743}"
|
||||
EndProject
|
||||
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "WelsonJS.Cryptography", "WelsonJS.Cryptography\WelsonJS.Cryptography.vbproj", "{577A0EA3-0E02-4099-8ECA-4E8DC7339C69}"
|
||||
EndProject
|
||||
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "WelsonJS.Cryptography.Test", "WelsonJS.Cryptography.Test\WelsonJS.Cryptography.Test.vbproj", "{C65EC34B-71C7-47CF-912E-D304283EB412}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -59,8 +63,24 @@ Global
|
|||
{783F2DB2-80D0-4F58-A55E-9593E44D5743}.Debug|x86.Build.0 = Debug|x86
|
||||
{783F2DB2-80D0-4F58-A55E-9593E44D5743}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{783F2DB2-80D0-4F58-A55E-9593E44D5743}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{783F2DB2-80D0-4F58-A55E-9593E44D5743}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{783F2DB2-80D0-4F58-A55E-9593E44D5743}.Release|x86.Build.0 = Release|Any CPU
|
||||
{783F2DB2-80D0-4F58-A55E-9593E44D5743}.Release|x86.ActiveCfg = Release|x86
|
||||
{783F2DB2-80D0-4F58-A55E-9593E44D5743}.Release|x86.Build.0 = Release|x86
|
||||
{577A0EA3-0E02-4099-8ECA-4E8DC7339C69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{577A0EA3-0E02-4099-8ECA-4E8DC7339C69}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{577A0EA3-0E02-4099-8ECA-4E8DC7339C69}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{577A0EA3-0E02-4099-8ECA-4E8DC7339C69}.Debug|x86.Build.0 = Debug|x86
|
||||
{577A0EA3-0E02-4099-8ECA-4E8DC7339C69}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{577A0EA3-0E02-4099-8ECA-4E8DC7339C69}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{577A0EA3-0E02-4099-8ECA-4E8DC7339C69}.Release|x86.ActiveCfg = Release|x86
|
||||
{577A0EA3-0E02-4099-8ECA-4E8DC7339C69}.Release|x86.Build.0 = Release|x86
|
||||
{C65EC34B-71C7-47CF-912E-D304283EB412}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C65EC34B-71C7-47CF-912E-D304283EB412}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C65EC34B-71C7-47CF-912E-D304283EB412}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{C65EC34B-71C7-47CF-912E-D304283EB412}.Debug|x86.Build.0 = Debug|x86
|
||||
{C65EC34B-71C7-47CF-912E-D304283EB412}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C65EC34B-71C7-47CF-912E-D304283EB412}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C65EC34B-71C7-47CF-912E-D304283EB412}.Release|x86.ActiveCfg = Release|x86
|
||||
{C65EC34B-71C7-47CF-912E-D304283EB412}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user