diff --git a/.gitignore b/.gitignore index bbbfb71..5b5c065 100644 --- a/.gitignore +++ b/.gitignore @@ -22,8 +22,13 @@ Thumbs.db *.lib *.sbr obj/ +.vs/ [Rr]elease*/ _ReSharper*/ [Tt]est[Rr]esult* out/ -build/ \ No newline at end of file +build/ + +/.vs +/bin +/obj \ No newline at end of file diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs deleted file mode 100644 index 3ba2e1b..0000000 --- a/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -[assembly: AssemblyCompany("Xormis")] -[assembly: AssemblyProduct("SimpleCrypto.Net")] -[assembly: AssemblyCopyright("Shawn Mclean (c) 2013")] -[assembly: AssemblyVersion("0.3.0.0")] -[assembly: AssemblyFileVersion("0.3.0.0")] diff --git a/LICENSE.txt b/LICENSE.txt index 95a080a..a155884 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2013 Shawn Mclean and other SimpleCrypto.Net contributors. +Copyright 2024 hipperbyte from original Copyright 2013 Shawn Mclean and other SimpleCrypto.Net contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 0c2c87c..a55d58d 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,15 @@ -[![NuGet](http://img.shields.io/nuget/v/SimpleCrypto.svg?style=flat-square)](https://www.nuget.org/packages/SimpleCrypto/) -[![Downloads](http://img.shields.io/nuget/dt/SimpleCrypto.svg?style=flat-square)](https://www.nuget.org/packages/SimpleCrypto/) -[![Build Status](http://img.shields.io/teamcity/codebetter/bt964.svg?style=flat-square)](http://teamcity.codebetter.com/project.html?projectId=project321&guest=1) -[![Code Coverage](http://img.shields.io/teamcity/coverage/bt964.svg?style=flat-square)](http://teamcity.codebetter.com/project.html?projectId=project321&guest=1) +[![NuGet](http://img.shields.io/nuget/v/net7-SimpleCrypto.svg?style=flat-square)](https://www.nuget.org/packages/net7-SimpleCrypto/) +[![Downloads](http://img.shields.io/nuget/dt/net7-SimpleCrypto.svg?style=flat-square)](https://www.nuget.org/packages/net7-SimpleCrypto/) -# SimpleCrypto.Net + +# SimpleCrypto.Net (.net 7 version) ## NuGet Visual Studio users can install this directly into their .NET projects by executing the following command in the [Package Manager Console](http://docs.nuget.org/docs/start-here/using-the-package-manager-console) - PM> Install-Package SimpleCrypto + PM> Install-Package net7-SimpleCrypto ## Description @@ -64,5 +63,7 @@ SimpleCrypto.NET is licensed with the Apache License, version 2.0. You can find ##Changelog - 1. **0.3.0.0 - March 14, 2013** - Generate Salt feature added. - 2. **0.2.0.0 - September 16, 2012** - Generate Random password feature added. + 1. **0.4.0.0 - March 07, 2023** - Updated version of source project to .net7. + 2. **0.3.0.0 - March 14, 2013** - Generate Salt feature added. + 3. **0.2.0.0 - September 16, 2012** - Generate Random password feature added. + diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 2712d69..0000000 --- a/Rakefile +++ /dev/null @@ -1,70 +0,0 @@ -require 'albacore' -require 'version_bumper' - -task :deploy => [:zip, :nup] do -end - -zip :zip => :output do | zip | - Dir.mkdir("build") unless Dir.exists?("build") - zip.directories_to_zip "out" - zip.output_file = "SimpleCrypto.v#{bumper_version.to_s}.zip" - zip.output_path = "build" -end - -output :output => :test do |out| - out.from '.' - out.to 'out' - out.file 'src/bin/release/SimpleCrypto.dll', :as=>'SimpleCrypto.dll' - out.file 'LICENSE.txt' - out.file 'README.md' -end - -desc "Test" -nunit :test => :build do |nunit| - nunit.command = "tools/NUnit/nunit-console.exe" - nunit.assemblies "tests/bin/release/SimpleCrypto.Tests.dll" -end - -desc "Build" -msbuild :build => :assemblyinfo do |msb| - msb.properties :configuration => :Release - msb.targets :Clean, :Build - msb.solution = "SimpleCrypto.sln" -end - -##This does not work from albacore. -#nugetpack :nup => :nus do |nuget| -# nuget.command = "tools/NuGet/NuGet.exe" -# nuget.nuspec = "SimpleCrypto.nuspec" -# nuget.base_folder = "out/" -# nuget.output = "build/" -#end - -##use this until patched -task :nup => :nus do - sh "tools/NuGet/NuGet.exe pack -BasePath out/ -Output build/ out/SimpleCrypto.nuspec" -end - -nuspec :nus => :output do |nuspec| - nuspec.id="SimpleCrypto" - nuspec.version = bumper_version.to_s - nuspec.authors = "Shawn Mclean" - nuspec.description = "Simple cryptography library that wraps complex hashing algorithms for quick and simple usage." - nuspec.title = "SimpleCrypto.Net" - nuspec.language = "en-US" - nuspec.projectUrl = "https://github.com/ShawnMclean/SimpleCrypto.net" - nuspec.working_directory = "out/" - nuspec.output_file = "SimpleCrypto.nuspec" - nuspec.file "SimpleCrypto.dll", "lib" -end - - -assemblyinfo :assemblyinfo do |asm| - asm.version = bumper_version.to_s - asm.file_version = bumper_version.to_s - - asm.company_name = "Xormis" - asm.product_name = "SimpleCrypto.Net" - asm.copyright = "Shawn Mclean (c) 2013" - asm.output_file = "AssemblyInfo.cs" -end \ No newline at end of file diff --git a/SimpleCrypto.sln b/SimpleCrypto.sln index d174669..244fa97 100644 --- a/SimpleCrypto.sln +++ b/SimpleCrypto.sln @@ -1,46 +1,43 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33424.131 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FA42616F-B196-477E-B1C7-8AA8F7A2500E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D62D959A-C755-40AB-A773-0730D961BD16}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCrypto", "src\SimpleCrypto.csproj", "{ED8C6AD7-6CB7-4D5D-9A8F-C6E259DA40D9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCrypto.Tests", "tests\SimpleCrypto.Tests.csproj", "{27FA9E8D-A1F3-4963-BF60-9DF623B86D58}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C2AB8C95-5AAF-42BC-B435-55E248A263F7}" - ProjectSection(SolutionItems) = preProject - AssemblyInfo.cs = AssemblyInfo.cs - LICENSE.txt = LICENSE.txt - nuspec.nuspec = nuspec.nuspec - Rakefile = Rakefile - README.md = README.md - VERSION = VERSION - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{AB6F4545-9DC4-46A2-B5B7-66C4EB396BDF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCrypto.Tests", "tests\SimpleCrypto.Tests\SimpleCrypto.Tests.csproj", "{BD2D732A-3ED2-47E1-B7A7-FC70A87A7FFE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleCrypto", "src\SimpleCrypto.csproj", "{8040A9F4-9B9E-4D56-801E-FC5A48D74957}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {ED8C6AD7-6CB7-4D5D-9A8F-C6E259DA40D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED8C6AD7-6CB7-4D5D-9A8F-C6E259DA40D9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ED8C6AD7-6CB7-4D5D-9A8F-C6E259DA40D9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ED8C6AD7-6CB7-4D5D-9A8F-C6E259DA40D9}.Release|Any CPU.Build.0 = Release|Any CPU - {27FA9E8D-A1F3-4963-BF60-9DF623B86D58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {27FA9E8D-A1F3-4963-BF60-9DF623B86D58}.Debug|Any CPU.Build.0 = Debug|Any CPU - {27FA9E8D-A1F3-4963-BF60-9DF623B86D58}.Release|Any CPU.ActiveCfg = Release|Any CPU - {27FA9E8D-A1F3-4963-BF60-9DF623B86D58}.Release|Any CPU.Build.0 = Release|Any CPU + {BD2D732A-3ED2-47E1-B7A7-FC70A87A7FFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD2D732A-3ED2-47E1-B7A7-FC70A87A7FFE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD2D732A-3ED2-47E1-B7A7-FC70A87A7FFE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD2D732A-3ED2-47E1-B7A7-FC70A87A7FFE}.Release|Any CPU.Build.0 = Release|Any CPU + {8040A9F4-9B9E-4D56-801E-FC5A48D74957}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8040A9F4-9B9E-4D56-801E-FC5A48D74957}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8040A9F4-9B9E-4D56-801E-FC5A48D74957}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8040A9F4-9B9E-4D56-801E-FC5A48D74957}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {ED8C6AD7-6CB7-4D5D-9A8F-C6E259DA40D9} = {FA42616F-B196-477E-B1C7-8AA8F7A2500E} - {27FA9E8D-A1F3-4963-BF60-9DF623B86D58} = {D62D959A-C755-40AB-A773-0730D961BD16} + {BD2D732A-3ED2-47E1-B7A7-FC70A87A7FFE} = {D62D959A-C755-40AB-A773-0730D961BD16} + {8040A9F4-9B9E-4D56-801E-FC5A48D74957} = {FA42616F-B196-477E-B1C7-8AA8F7A2500E} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3D7529AC-A8B0-4194-845A-3F488AF50873} EndGlobalSection EndGlobal diff --git a/VERSION b/VERSION deleted file mode 100644 index 73082a8..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.3.0.0 \ No newline at end of file diff --git a/lib/Nunit/nunit.framework.dll b/lib/Nunit/nunit.framework.dll deleted file mode 100644 index eaea9ee..0000000 Binary files a/lib/Nunit/nunit.framework.dll and /dev/null differ diff --git a/nuspec.nuspec b/nuspec.nuspec deleted file mode 100644 index 27d1a97..0000000 --- a/nuspec.nuspec +++ /dev/null @@ -1,19 +0,0 @@ - - - - SimpleCrypto - 0.0 - SimpleCrypto.Net - Shawn Mclean - Shawn Mclean - https://github.com/shawnmclean/SimpleCrypto.net - false - Simple cryptography library that wraps complex hashing algorithms such as PBKDF2 for quick and simple usage. - Added visual studio documentation to classes. - 2013 - en-US - - - - - \ No newline at end of file diff --git a/src/Interfaces/ICryptoService.cs b/src/Interfaces/ICryptoService.cs index 81a9b1b..1b30493 100644 --- a/src/Interfaces/ICryptoService.cs +++ b/src/Interfaces/ICryptoService.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -//using System.Threading.Tasks; - -namespace SimpleCrypto +namespace SimpleCrypto { /// /// Interface for Simple Crypto Service @@ -35,7 +29,7 @@ public interface ICryptoService /// Gets or sets the salt that will be used in computing the HashedText. This contains both Salt and HashIterations. /// string Salt { get; set; } - + /// /// Compute the hash /// @@ -86,7 +80,7 @@ public interface ICryptoService /// /// int GetElapsedTimeForIteration(int iteration); - + /// /// Compare the passwords for equality /// The first password hash to compare diff --git a/src/PBKDF2.cs b/src/PBKDF2.cs index 7665e71..0f663d6 100644 --- a/src/PBKDF2.cs +++ b/src/PBKDF2.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; +using System.Diagnostics; using System.Security.Cryptography; using System.Text; -//using System.Threading.Tasks; + namespace SimpleCrypto { @@ -183,8 +180,7 @@ private string calculateHash(int iteration) { //convert the salt into a byte array byte[] saltBytes = Encoding.UTF8.GetBytes(Salt); - - var pbkdf2 = new Rfc2898DeriveBytes(PlainText, saltBytes, iteration); + var pbkdf2 = new Rfc2898DeriveBytes(PlainText, saltBytes, iteration,HashAlgorithmName.SHA1); var key = pbkdf2.GetBytes(64); return Convert.ToBase64String(key); } diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs deleted file mode 100644 index 33c7b50..0000000 --- a/src/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -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("SimpleCrypto")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SimpleCrypto")] -[assembly: AssemblyCopyright("Copyright © 2012")] -[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("12f8c253-86f5-4f21-9060-7a7c33bae22d")] - -// 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")] diff --git a/src/RandomPassword.cs b/src/RandomPassword.cs index a475514..ef3c064 100644 --- a/src/RandomPassword.cs +++ b/src/RandomPassword.cs @@ -4,11 +4,7 @@ // Copyright (C) 2004 Obviex(TM). All rights reserved. // -using System; -using System.Collections.Generic; -using System.Linq; using System.Security.Cryptography; -using System.Text; namespace SimpleCrypto { diff --git a/src/SimpleCrypto.csproj b/src/SimpleCrypto.csproj index e8fa977..a202e01 100644 --- a/src/SimpleCrypto.csproj +++ b/src/SimpleCrypto.csproj @@ -1,51 +1,35 @@ - - - + + - Debug - AnyCPU - {ED8C6AD7-6CB7-4D5D-9A8F-C6E259DA40D9} - Library - Properties - SimpleCrypto - SimpleCrypto - v3.5 - 512 - Client + net7.0 + enable + enable + True + LICENSE.txt + Simple cryptography library that wraps complex hashing algorithms for quick and simple usage. + hipperbyte + Forked Version of original SimpleCrypto by Shawn Mclean (https://github.com/shawnmclean/SimpleCrypto.net), modifyed and updated for .net 7 + hipperbyte (c) 2023 + README.md + https://github.com/hipperbyte/SimpleCrypto.net/tree/net7update + This version of tool whas updated to .net7 + net7-$(AssemblyName) + net7-$(AssemblyName) + en + 0.4.0.1 + 0.4.0.1 + 0.4.0.1 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AnyCPU - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - + - + + True + \ + + + True + \ + - - - \ No newline at end of file + + diff --git a/src/VERSION b/src/VERSION new file mode 100644 index 0000000..3d2da89 --- /dev/null +++ b/src/VERSION @@ -0,0 +1 @@ +0.4.0.0 \ No newline at end of file diff --git a/tests/Properties/AssemblyInfo.cs b/tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 3d83c71..0000000 --- a/tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -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("SimpleCrypto.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SimpleCrypto.Tests")] -[assembly: AssemblyCopyright("Copyright © 2012")] -[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("a8234fc6-a267-40de-9ced-8e41375bc2c8")] - -// 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")] diff --git a/tests/SimpleCrypto.Tests.csproj b/tests/SimpleCrypto.Tests.csproj deleted file mode 100644 index c2023f7..0000000 --- a/tests/SimpleCrypto.Tests.csproj +++ /dev/null @@ -1,67 +0,0 @@ - - - - Debug - AnyCPU - {27FA9E8D-A1F3-4963-BF60-9DF623B86D58} - Library - Properties - SimpleCrypto.Tests - SimpleCrypto.Tests - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - UnitTest - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\lib\Nunit\nunit.framework.dll - - - - - - - - - - - - - - - - - - - {ed8c6ad7-6cb7-4d5d-9a8f-c6e259da40d9} - SimpleCrypto - - - - - \ No newline at end of file diff --git a/tests/PBKDF2Tests.cs b/tests/SimpleCrypto.Tests/PBKDF2Tests.cs similarity index 98% rename from tests/PBKDF2Tests.cs rename to tests/SimpleCrypto.Tests/PBKDF2Tests.cs index 4af5b9f..5afac6b 100644 --- a/tests/PBKDF2Tests.cs +++ b/tests/SimpleCrypto.Tests/PBKDF2Tests.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics; -using NUnit.Framework; +using NUnit.Framework; namespace SimpleCrypto.Tests { @@ -143,7 +141,8 @@ public void Generate_Salt_Has_Correct_Hash_Iterations() } [Test] - [Ignore] + [Ignore("")] + public void Generate_Salt_Has_Correct_Salt_Size() { var crypto = CreateICryptoService(); @@ -176,9 +175,9 @@ public void Comparison_To_Same_Hash_Returns_True() var hash2 = crypto.Compute("password", salt); - Assert.IsTrue(crypto.Compare(hash1, hash2), "Hash comparison fails"); - - var hash3 = crypto.Compute("pasw1rd", salt); + Assert.IsTrue(crypto.Compare(hash1, hash2), "Hash comparison fails"); + + var hash3 = crypto.Compute("pasw1rd", salt); Assert.IsFalse(crypto.Compare(hash1, hash3), "Hash comparison should fail but didn't"); } } diff --git a/tests/RandomPasswordTests.cs b/tests/SimpleCrypto.Tests/RandomPasswordTests.cs similarity index 92% rename from tests/RandomPasswordTests.cs rename to tests/SimpleCrypto.Tests/RandomPasswordTests.cs index f45cc51..6096673 100644 --- a/tests/RandomPasswordTests.cs +++ b/tests/SimpleCrypto.Tests/RandomPasswordTests.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using NUnit.Framework; using System.Text.RegularExpressions; -using System.Threading.Tasks; -using NUnit.Framework; namespace SimpleCrypto.Tests { diff --git a/tests/SimpleCrypto.Tests/SimpleCrypto.Tests.csproj b/tests/SimpleCrypto.Tests/SimpleCrypto.Tests.csproj new file mode 100644 index 0000000..d5fcef6 --- /dev/null +++ b/tests/SimpleCrypto.Tests/SimpleCrypto.Tests.csproj @@ -0,0 +1,23 @@ + + + + net7.0 + enable + enable + + false + + + + + + + + + + + + + + +