diff --git a/osrepodbmgr.sln b/osrepodbmgr.sln index 669c080..4cd29c9 100644 --- a/osrepodbmgr.sln +++ b/osrepodbmgr.sln @@ -3,6 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osrepodbmgr", "osrepodbmgr\osrepodbmgr.csproj", "{19FB7436-031F-42B3-87F6-8508F63EDADA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Checksums", "DiscImageChef\DiscImageChef.Checksums\DiscImageChef.Checksums.csproj", "{CC48B324-A532-4A45-87A6-6F91F7141E8D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Helpers", "DiscImageChef\DiscImageChef.Helpers\DiscImageChef.Helpers.csproj", "{F8BDF57B-1571-4CD0-84B3-B422088D359A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Console", "DiscImageChef\DiscImageChef.Console\DiscImageChef.Console.csproj", "{CCAA7AFE-C094-4D82-A66D-630DE8A3F545}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -13,6 +19,18 @@ Global {19FB7436-031F-42B3-87F6-8508F63EDADA}.Debug|x86.Build.0 = Debug|x86 {19FB7436-031F-42B3-87F6-8508F63EDADA}.Release|x86.ActiveCfg = Release|x86 {19FB7436-031F-42B3-87F6-8508F63EDADA}.Release|x86.Build.0 = Release|x86 + {CC48B324-A532-4A45-87A6-6F91F7141E8D}.Debug|x86.ActiveCfg = Debug|Any CPU + {CC48B324-A532-4A45-87A6-6F91F7141E8D}.Debug|x86.Build.0 = Debug|Any CPU + {CC48B324-A532-4A45-87A6-6F91F7141E8D}.Release|x86.ActiveCfg = Release|Any CPU + {CC48B324-A532-4A45-87A6-6F91F7141E8D}.Release|x86.Build.0 = Release|Any CPU + {F8BDF57B-1571-4CD0-84B3-B422088D359A}.Debug|x86.ActiveCfg = Debug|Any CPU + {F8BDF57B-1571-4CD0-84B3-B422088D359A}.Debug|x86.Build.0 = Debug|Any CPU + {F8BDF57B-1571-4CD0-84B3-B422088D359A}.Release|x86.ActiveCfg = Release|Any CPU + {F8BDF57B-1571-4CD0-84B3-B422088D359A}.Release|x86.Build.0 = Release|Any CPU + {CCAA7AFE-C094-4D82-A66D-630DE8A3F545}.Debug|x86.ActiveCfg = Debug|Any CPU + {CCAA7AFE-C094-4D82-A66D-630DE8A3F545}.Debug|x86.Build.0 = Debug|Any CPU + {CCAA7AFE-C094-4D82-A66D-630DE8A3F545}.Release|x86.ActiveCfg = Release|Any CPU + {CCAA7AFE-C094-4D82-A66D-630DE8A3F545}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 diff --git a/osrepodbmgr/ChangeLog b/osrepodbmgr/ChangeLog index db02c10..55ed6e1 100644 --- a/osrepodbmgr/ChangeLog +++ b/osrepodbmgr/ChangeLog @@ -1,3 +1,10 @@ +2017-04-29 Natalia Portillo + + * Core.cs: + * SHA256Context.cs: + * osrepodbmgr.csproj: + Use SHA256 algorithm from DiscImageChef. + 2017-04-29 Natalia Portillo * Core.cs: diff --git a/osrepodbmgr/Core.cs b/osrepodbmgr/Core.cs index 213fcd0..42adae7 100644 --- a/osrepodbmgr/Core.cs +++ b/osrepodbmgr/Core.cs @@ -33,6 +33,7 @@ using System.Linq; using System.Text; using System.Xml; using System.Xml.Serialization; +using DiscImageChef.Checksums; using Ionic.Zip; using Newtonsoft.Json; using Schemas; diff --git a/osrepodbmgr/SHA256Context.cs b/osrepodbmgr/SHA256Context.cs deleted file mode 100644 index 6a4976a..0000000 --- a/osrepodbmgr/SHA256Context.cs +++ /dev/null @@ -1,152 +0,0 @@ -// -// Author: -// Natalia Portillo claunia@claunia.com -// -// Copyright (c) 2017, © Claunia.com -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the distribution. -// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -using System.IO; -using System.Security.Cryptography; -using System.Text; - -namespace osrepodbmgr -{ - /// - /// Provides a UNIX similar API to .NET SHA256. - /// - public class SHA256Context - { - SHA256 _sha256Provider; - - /// - /// Initializes the SHA256 hash provider - /// - public void Init() - { - _sha256Provider = SHA256.Create(); - } - - /// - /// Updates the hash with data. - /// - /// Data buffer. - /// Length of buffer to hash. - public void Update(byte[] data, uint len) - { - _sha256Provider.TransformBlock(data, 0, (int)len, data, 0); - } - - /// - /// Updates the hash with data. - /// - /// Data buffer. - public void Update(byte[] data) - { - Update(data, (uint)data.Length); - } - - /// - /// Returns a byte array of the hash value. - /// - public byte[] Final() - { - _sha256Provider.TransformFinalBlock(new byte[0], 0, 0); - return _sha256Provider.Hash; - } - - /// - /// Returns a hexadecimal representation of the hash value. - /// - public string End() - { - _sha256Provider.TransformFinalBlock(new byte[0], 0, 0); - StringBuilder sha256Output = new StringBuilder(); - - for(int i = 0; i < _sha256Provider.Hash.Length; i++) - { - sha256Output.Append(_sha256Provider.Hash[i].ToString("x2")); - } - - return sha256Output.ToString(); - } - - /// - /// Gets the hash of a file - /// - /// File path. - public byte[] File(string filename) - { - FileStream fileStream = new FileStream(filename, FileMode.Open); - return _sha256Provider.ComputeHash(fileStream); - } - - /// - /// Gets the hash of a file in hexadecimal and as a byte array. - /// - /// File path. - /// Byte array of the hash value. - public string File(string filename, out byte[] hash) - { - FileStream fileStream = new FileStream(filename, FileMode.Open); - hash = _sha256Provider.ComputeHash(fileStream); - StringBuilder sha256Output = new StringBuilder(); - - for(int i = 0; i < hash.Length; i++) - { - sha256Output.Append(hash[i].ToString("x2")); - } - - return sha256Output.ToString(); - } - - /// - /// Gets the hash of the specified data buffer. - /// - /// Data buffer. - /// Length of the data buffer to hash. - /// Byte array of the hash value. - public string Data(byte[] data, uint len, out byte[] hash) - { - hash = _sha256Provider.ComputeHash(data, 0, (int)len); - StringBuilder sha256Output = new StringBuilder(); - - for(int i = 0; i < hash.Length; i++) - { - sha256Output.Append(hash[i].ToString("x2")); - } - - return sha256Output.ToString(); - } - - /// - /// Gets the hash of the specified data buffer. - /// - /// Data buffer. - /// Byte array of the hash value. - public string Data(byte[] data, out byte[] hash) - { - return Data(data, (uint)data.Length, out hash); - } - } -} - diff --git a/osrepodbmgr/osrepodbmgr.csproj b/osrepodbmgr/osrepodbmgr.csproj index 08e31d1..66e9457 100644 --- a/osrepodbmgr/osrepodbmgr.csproj +++ b/osrepodbmgr/osrepodbmgr.csproj @@ -79,7 +79,6 @@ - @@ -97,6 +96,12 @@ + + + {CC48B324-A532-4A45-87A6-6F91F7141E8D} + DiscImageChef.Checksums + + \ No newline at end of file