0 Members and 1 Guest are viewing this topic.
namespace LispBase{ public class Commands { //(MD5 "MD5") [LispFunction("MD5")] public static ResultBuffer test1(ResultBuffer args) { ResultBuffer retList = new ResultBuffer(); try { Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor; if (args == null) { retList.AddErr("Null Argument"); return retList; } if (args.GetCount() == 0) { retList.AddErr("To Few Arguments"); return retList; } if (args.GetCount() == 2) { retList.AddErr("To Many Arguments"); return retList; } string StrMd5 = HashString(Convert.ToString(args.AsArray()[0].Value)); retList.AddString(StrMd5); } catch (System.Exception ex) { retList.AddErr(ex.Message); } return retList; } private static string HashString(string Value) { System.Security.Cryptography.MD5CryptoServiceProvider MD5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] data = System.Text.Encoding.ASCII.GetBytes(Value); data = MD5.ComputeHash(data); StringBuilder sb = new StringBuilder(data.Length); for (int i = 0; i < data.Length; i++) sb.Append(data[i].ToString("x2").ToLower()); return sb.ToString(); } }}