home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
Fanart Handler
Mixed artist pictures
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="horned_reaper" data-source="post: 1270050" data-attributes="member: 109929"><p>What about comparing the hash value of a new picture with the has values of the other (maximum 9) stored pictures of an artist before storing it?</p><p>[CODE]using System;</p><p>using System.Security.Cryptography;</p><p>using System.Text;</p><p></p><p>namespace ComputeAHash_csharp</p><p>{</p><p>/// <summary></p><p>/// Summary description for Class1.</p><p>/// </summary></p><p>class Class1</p><p>{</p><p>static void Main(string[] args)</p><p>{</p><p>string sSourceData;</p><p>byte[] tmpSource;</p><p>byte[] tmpHash;</p><p>sSourceData = "MySourceData";</p><p>//Create a byte array from source data</p><p>tmpSource = ASCIIEncoding.ASCII.GetBytes(sSourceData);</p><p></p><p>//Compute hash based on source data</p><p>tmpHash = new MD5CryptoServiceProvider().ComputeHash(tmpSource);</p><p>Console.WriteLine(ByteArrayToString(tmpHash));</p><p></p><p>sSourceData = "NotMySourceData";</p><p>tmpSource = ASCIIEncoding.ASCII.GetBytes(sSourceData);</p><p></p><p>byte[] tmpNewHash;</p><p></p><p>tmpNewHash = new MD5CryptoServiceProvider().ComputeHash(tmpSource);</p><p></p><p>bool bEqual = false;</p><p>if (tmpNewHash.Length == tmpHash.Length)</p><p>{</p><p>int i=0;</p><p>while ((i < tmpNewHash.Length) && (tmpNewHash[i] == tmpHash[i]))</p><p>{</p><p>i += 1;</p><p>}</p><p>if (i == tmpNewHash.Length)</p><p>{</p><p>bEqual = true;</p><p>}</p><p>}</p><p></p><p> if (bEqual)</p><p> Console.WriteLine("The two hash values are the same");</p><p> else</p><p> Console.WriteLine("The two hash values are not the same");</p><p> Console.ReadLine();</p><p>}</p><p></p><p>static string ByteArrayToString(byte[] arrInput)</p><p>{</p><p>int i;</p><p>StringBuilder sOutput = new StringBuilder(arrInput.Length);</p><p>for (i=0;i < arrInput.Length -1; i++)</p><p>{</p><p>sOutput.Append(arrInput[i].ToString("X2"));</p><p>}</p><p>return sOutput.ToString();</p><p>}</p><p>}</p><p>}[/CODE]</p><p></p><p>[URL unfurl="true"]https://support.microsoft.com/en-za/help/307020/how-to-compute-and-compare-hash-values-by-using-visual-c[/URL]</p></blockquote><p></p>
[QUOTE="horned_reaper, post: 1270050, member: 109929"] What about comparing the hash value of a new picture with the has values of the other (maximum 9) stored pictures of an artist before storing it? [CODE]using System; using System.Security.Cryptography; using System.Text; namespace ComputeAHash_csharp { /// <summary> /// Summary description for Class1. /// </summary> class Class1 { static void Main(string[] args) { string sSourceData; byte[] tmpSource; byte[] tmpHash; sSourceData = "MySourceData"; //Create a byte array from source data tmpSource = ASCIIEncoding.ASCII.GetBytes(sSourceData); //Compute hash based on source data tmpHash = new MD5CryptoServiceProvider().ComputeHash(tmpSource); Console.WriteLine(ByteArrayToString(tmpHash)); sSourceData = "NotMySourceData"; tmpSource = ASCIIEncoding.ASCII.GetBytes(sSourceData); byte[] tmpNewHash; tmpNewHash = new MD5CryptoServiceProvider().ComputeHash(tmpSource); bool bEqual = false; if (tmpNewHash.Length == tmpHash.Length) { int i=0; while ((i < tmpNewHash.Length) && (tmpNewHash[i] == tmpHash[i])) { i += 1; } if (i == tmpNewHash.Length) { bEqual = true; } } if (bEqual) Console.WriteLine("The two hash values are the same"); else Console.WriteLine("The two hash values are not the same"); Console.ReadLine(); } static string ByteArrayToString(byte[] arrInput) { int i; StringBuilder sOutput = new StringBuilder(arrInput.Length); for (i=0;i < arrInput.Length -1; i++) { sOutput.Append(arrInput[i].ToString("X2")); } return sOutput.ToString(); } } }[/CODE] [URL unfurl="true"]https://support.microsoft.com/en-za/help/307020/how-to-compute-and-compare-hash-values-by-using-visual-c[/URL] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
Fanart Handler
Mixed artist pictures
Contact us
RSS
Top
Bottom