[banshee] [Hyena.Data.Sqlite] Add HYENA_MD5 method



commit 5b6918eb9efb70bd1047a7b869d3d1a946307e1d
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Thu May 13 16:35:57 2010 -0700

    [Hyena.Data.Sqlite] Add HYENA_MD5 method
    
    Available in SQL statements; first arg is the # of args, and the
    following are objects that will be added to a StringBuffer and MD5'd.

 .../Hyena/Hyena.Data.Sqlite/SqliteUtils.cs         |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs b/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs
index 979ccb3..31a8626 100644
--- a/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs
+++ b/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs
@@ -194,4 +194,18 @@ namespace Hyena.Data.Sqlite
             return Hyena.StringUtil.SearchKey (args[0] as string);
         }
     }
+
+    [SqliteFunction (Name = "HYENA_MD5", FuncType = FunctionType.Scalar, Arguments = -1)]
+    internal class Md5Function : SqliteFunction
+    {
+        public override object Invoke (object[] args)
+        {
+            int n_args = (int)(long) args[0];
+            var sb = new StringBuilder ();
+            for (int i = 1; i <= n_args; i++) {
+                sb.Append (args[i]);
+            }
+            return Hyena.CryptoUtil.Md5Encode (sb.ToString (), System.Text.Encoding.UTF8);
+        }
+    }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]