aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs35
1 files changed, 30 insertions, 5 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index e5ff27a..fce8999 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -324,10 +324,25 @@ namespace OpenSim.Framework
324 } 324 }
325 325
326 /// <summary> 326 /// <summary>
327 /// Debug utility function to convert OSD into formatted XML for debugging purposes.
328 /// </summary>
329 /// <param name="osd">
330 /// A <see cref="OSD"/>
331 /// </param>
332 /// <returns>
333 /// A <see cref="System.String"/>
334 /// </returns>
335 public static string GetFormattedXml(OSD osd)
336 {
337 return GetFormattedXml(OSDParser.SerializeLLSDXmlString(osd));
338 }
339
340 /// <summary>
327 /// Debug utility function to convert unbroken strings of XML into something human readable for occasional debugging purposes. 341 /// Debug utility function to convert unbroken strings of XML into something human readable for occasional debugging purposes.
328 ///
329 /// Please don't delete me even if I appear currently unused!
330 /// </summary> 342 /// </summary>
343 /// <remarks>
344 /// Please don't delete me even if I appear currently unused!
345 /// </remarks>
331 /// <param name="rawXml"></param> 346 /// <param name="rawXml"></param>
332 /// <returns></returns> 347 /// <returns></returns>
333 public static string GetFormattedXml(string rawXml) 348 public static string GetFormattedXml(string rawXml)
@@ -425,20 +440,30 @@ namespace OpenSim.Framework
425 } 440 }
426 441
427 /// <summary> 442 /// <summary>
428 /// Return an SHA1 hash of the given string 443 /// Return an SHA1 hash
429 /// </summary> 444 /// </summary>
430 /// <param name="data"></param> 445 /// <param name="data"></param>
431 /// <returns></returns> 446 /// <returns></returns>
432 public static string SHA1Hash(string data) 447 public static string SHA1Hash(string data)
433 { 448 {
449 return SHA1Hash(Encoding.Default.GetBytes(data));
450 }
451
452 /// <summary>
453 /// Return an SHA1 hash
454 /// </summary>
455 /// <param name="data"></param>
456 /// <returns></returns>
457 public static string SHA1Hash(byte[] data)
458 {
434 byte[] hash = ComputeSHA1Hash(data); 459 byte[] hash = ComputeSHA1Hash(data);
435 return BitConverter.ToString(hash).Replace("-", String.Empty); 460 return BitConverter.ToString(hash).Replace("-", String.Empty);
436 } 461 }
437 462
438 private static byte[] ComputeSHA1Hash(string src) 463 private static byte[] ComputeSHA1Hash(byte[] src)
439 { 464 {
440 SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); 465 SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
441 return SHA1.ComputeHash(Encoding.Default.GetBytes(src)); 466 return SHA1.ComputeHash(src);
442 } 467 }
443 468
444 public static int fast_distance2d(int x, int y) 469 public static int fast_distance2d(int x, int y)