GetHashString() public static method

public static GetHashString ( byte input ) : string
input byte
return string
コード例 #1
0
ファイル: QueryState.cs プロジェクト: ravendb/silverlight
        public static string CreateQueryStateHash(QueryState state)
        {
            var spatialString = state.IsSpatialQuery ? string.Format("{0}{1}{2}{3}", state.SpatialFieldName, state.Latitude, state.Longitude, state.Radius) : "";
            var optionString  = string.Format("{0}{1}", state.UseTransformer, state.Transformer);

            return(MD5Core.GetHashString(state.IndexName + state.Query + spatialString + optionString));
        }
コード例 #2
0
        private static void vXr(string xr)
        {
            string currentdomain = string.Empty;

            try
            {
                Dictionary <string, string> pairs = new Dictionary <string, string>()
                {
                    { "localhost", "Ygcc560952xsHqevneGmXp0NF8aOUp5C" },
                    { "how-to-use-scanner-from-browser-webapp.com", "1zAK772b9v193A1ul6D3861U8Q4U961C" },
                    { "alquilermotosporhora.com", "1zAK772b9v193A1ul6D3861U8Q4U961C" }
                };

                currentdomain = GetMainDomain(System.Windows.Application.Current.Host.Source.Host);

                KeyValuePair <string, string> pair = pairs.FirstOrDefault(x => currentdomain == x.Key);

                string key  = MD5Core.GetHashString(xr + "_" + currentdomain);
                string vkey = MD5Core.GetHashString(pair.Value + "_" + pair.Key);

                if (key != vkey)
                {
                    throw new Exception(string.Format(moleQule.Tools.Qapture.Resources.Errors.LICENSE, currentdomain));
                }
            }
            catch
            {
                throw new Exception(string.Format(moleQule.Tools.Qapture.Resources.Errors.LICENSE, currentdomain));
            }
        }
コード例 #3
0
 public bool doSceneVoiceEx(string toUsername, int mMsgSrvId, int timeLenth, byte[] toSend)
 {
     base.beginBuilder();
     base.mBuilder.BaseRequest  = NetSceneBase.makeBaseRequest(0x13);
     base.mBuilder.FromUserName = AccountMgr.getCurAccount().strUsrName;
     base.mBuilder.ToUserName   = toUsername;
     base.mBuilder.Offset       = (uint)toSend.Length;
     base.mBuilder.Length       = (uint)toSend.Length;
     base.mBuilder.ClientMsgId  = MD5Core.GetHashString(toUsername + Util.getNowMilliseconds());
     base.mBuilder.MsgId        = (uint)mMsgSrvId;
     base.mBuilder.VoiceLength  = (uint)timeLenth;
     base.mBuilder.Data         = Util.toSKBuffer(toSend);
     //uint num = 0;
     //if (this.mVoiceContext.isEncodeAmrEnd() && ((this.mVoiceContext.mNetOffset + toSend.Length) >= this.mVoiceContext.mOutputLength))
     //{
     //    num = 1;
     //}
     base.mBuilder.EndFlag = 1;// num;
     //if (this.mVoiceContext.mIsCancelled)
     //{
     //    base.mBuilder.CancelFlag = 1;
     //    base.mBuilder.Data = Util.toSKBuffer("");
     //    base.mBuilder.Length = 0;
     //}
     base.mSessionPack.mCmdID = 0x13;
     base.endBuilder();
     return(true);
 }
コード例 #4
0
        public async Task <bool> libraryAddArtist(string artist)
        {
            string requestString = "api_key" + apiKey + "artist" + artist +
                                   "methodlibrary.addArtist" + "sk" + sk + "96bd810a71249530b5f3831cd09f43d1";

            string api_sig = MD5Core.GetHashString(requestString);
            var    request = new LFCRequest();

            request.addParameter("method", "library.addArtist");
            request.addParameter("artist", artist);
            request.addParameter("api_key", apiKey);
            request.addParameter("api_sig", api_sig);
            request.addParameter("sk", sk);

            var response = await request.execute();

            var json   = JObject.Parse(response);
            var result = json["status"];

            if (result.Value <string>().Equals("ok"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
        public static async Task <ERROR_ID> CreateAsync(string userID, string pw)
        {
            var hasUser = await CheckHasUserAsync(userID);

            if (hasUser)
            {
                return(ERROR_ID.CREATE_ACCOUNT_DUPLICATE);
            }


            var    uid      = UniqueSeqNumberGenerator.채번_받아오기();
            string hashPW   = MD5Core.GetHashString(pw);
            var    authUser = new DBUserAccountInfo()
            {
                _id = userID,
                PW  = hashPW,
                UID = uid,
            };

            var collection = Mongo.GetAccountDBCollection <DBUserAccountInfo>(COLLECTION_NAME);
            var result     = await Task.Run(() => collection.Insert <DBUserAccountInfo>(authUser));

            if (result.Ok == false)
            {
                return(ERROR_ID.CREATE_ACCOUNT_DB_FAIL);
            }

            return(ERROR_ID.NONE);
        }
コード例 #6
0
 public void TestLong()
 {
     foreach (var tuple in LongTestData)
     {
         Assert.AreEqual(tuple.Item2, MD5Core.GetHashString(tuple.Item1));
     }
 }
コード例 #7
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        static public async Task <RenrenAyncRespArgs <UserEntity> > LogIn(string username, string password)
        {
            password = MD5Core.GetHashString(password).ToLower();
            IDeviceInfoHelper deviceHelper = new DeviceInfoAdaptor(DeviceInfoAdaptor.ImplType.NETWORKADAPTOR);
            var deviceId = deviceHelper.GetDeviceID();

            var parameters = ApiHelper.GetBaseParameters(null).Result;

            parameters.Add(new RequestParameterEntity("api_key", ConstantValue.ApiKey));
            //parameters.Add(new RequestParameterEntity("method", Method.LogIn));
            parameters.Add(new RequestParameterEntity("uniq_id", deviceId));
            parameters.Add(new RequestParameterEntity("v", "1.0"));
            parameters.Add(new RequestParameterEntity("call_id", ApiHelper.GenerateTime()));
            parameters.Add(new RequestParameterEntity("password", password));
            parameters.Add(new RequestParameterEntity("user", username));

            string sig = ApiHelper.GenerateSig(parameters, ConstantValue.SecretKey);

            //if (sig.Length > 50)
            //    sig = sig.Substring(0, 50);
            parameters.Add(new RequestParameterEntity("sig", sig));

            var result = await agentReponseHandler <UserEntity, RenrenAyncRespArgs <UserEntity> >(parameters, ConstantValue.PostMethod, new Uri("http://api.m.renren.com/api/client/login", UriKind.Absolute));

            return(result);
        }
コード例 #8
0
        public async Task <List <LFCArtist> > userGetRecommendedArtists(string user)
        {
            List <LFCArtist> s             = new List <LFCArtist>();
            string           requestString = "api_key" + apiKey +
                                             "methoduser.getRecommendedArtists" + "sk" + sk + "96bd810a71249530b5f3831cd09f43d1";
            string api_sig = MD5Core.GetHashString(requestString);

            var request = new LFCRequest();

            request.addParameter("method", "user.getRecommendedArtists");
            request.addParameter("api_key", apiKey);
            request.addParameter("api_sig", api_sig);
            request.addParameter("sk", sk);

            try
            {
                JObject json    = JObject.Parse(await request.execute());
                var     artists = json["recommendations"]["artist"];
                foreach (JObject artist in artists)
                {
                    LFCArtist a = new LFCArtist();
                    a.Name  = artist.Value <string>("name");
                    a.Url   = artist.Value <string>("url");
                    a.Image = artist.Value <JArray>("image")[3]["#text"].Value <string>();
                    s.Add(a);
                }
            }
            catch (NullReferenceException e)
            {
                throw e;
            }
            return(s);
        }
コード例 #9
0
        public string getApiSig()
        {
            string requestString = "api_key" + apiKey +
                                   "methodauth.getmobilesession" + "password" +
                                   password + "username" + username + secretApiKey;

            return(MD5Core.GetHashString(requestString));
        }
コード例 #10
0
        /*
         * Returns MD5 hash from the imput string
         * */
        private string CalculateMd5Hash(string input)
        {
            UTF8Encoding enc        = new UTF8Encoding();
            var          inputBytes = enc.GetBytes(input);
            var          hash       = MD5Core.GetHashString(inputBytes).ToLower();

            return(hash.ToString());
        }
コード例 #11
0
ファイル: ExtensionsBase.cs プロジェクト: Makzz90/VKClient_re
 public static string GetShorterVersion(this string str)
 {
     if (string.IsNullOrEmpty(str) || str.Length < 32)
     {
         return(str);
     }
     return(MD5Core.GetHashString(str));
 }
コード例 #12
0
        public void Handle(UploadableItem item)
        {
            var userSelf = item.Owner as TLUserSelf;

            if (userSelf != null)
            {
                MTProtoService.UploadProfilePhotoAsync(
                    new TLInputFile
                {
                    Id          = item.FileId,
                    MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()),
                    Name        = new TLString(Guid.NewGuid() + ".jpg"),
                    Parts       = new TLInt(item.Parts.Count)
                },
                    new TLString(""),
                    new TLInputGeoPointEmpty(),
                    new TLInputPhotoCropAuto(),
                    photosPhoto =>
                {
                    MTProtoService.GetFullUserAsync(new TLInputUserSelf(), userFull => { }, error => { });
                },
                    error =>
                {
                });
                return;
            }


            var chat = item.Owner as TLChat;

            if (chat != null)
            {
                MTProtoService.EditChatPhotoAsync(
                    chat.Id,
                    new TLInputChatUploadedPhoto
                {
                    File = new TLInputFile
                    {
                        Id          = item.FileId,
                        MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()),
                        Name        = new TLString("chatPhoto.jpg"),
                        Parts       = new TLInt(item.Parts.Count)
                    },
                    Crop = new TLInputPhotoCropAuto()
                },
                    photosPhoto =>
                {
                    //MTProtoService.GetFullChatAsync((chat).Id, userFull =>
                    //{
                    //    //NotifyOfPropertyChange(() => CurrentItem);
                    //},
                    //error => { });
                },
                    error =>
                {
                });
            }
        }
コード例 #13
0
ファイル: MD5Core.cs プロジェクト: 07101994/BlueMarin
        public static string ToMD5(this String @this)
        {
            if (@this == null)
            {
                return(null);
            }

            return(MD5Core.GetHashString(@this));
        }
コード例 #14
0
 private static String _getOpenUDID()
 {
     _lastError = OpenUDIDErrors.None;
     if (_cachedValue == null)
     {
         _cachedValue = MD5Core.GetHashString(_getOldDeviceUniqueId());
     }
     return(_cachedValue);
 }
コード例 #15
0
 private bool canContinue(SnsSyncRequest request, SnsSyncResponse resp)
 {
     if (MD5Core.GetHashString(request.KeyBuf.Buffer.ToByteArray()) == MD5Core.GetHashString(NetSceneNewSync.mBytesSyncKeyBuf))
     {
         //Log.e("NetSceneSnsSync", " request sync key is equal to response sync key");
         return(false);
     }
     return((resp.ContinueFlag & 0x100) != 0);
 }
コード例 #16
0
 private bool canContinue(NewInitRequest request, NewInitResponse response)
 {
     if (MD5Core.GetHashString(request.CurrentSynckey.Buffer.ToByteArray()) == MD5Core.GetHashString(response.CurrentSynckey.Buffer.ToByteArray()))
     {
         Log.e("NetSceneNewInit", " request sync key is equal to response sync key");
         return(false);
     }
     return((response.ContinueFlag & this.mSelector) != 0L);
 }
コード例 #17
0
        public static void RemoveScore(ILeaderboardCaller caller)
        {
            Leaderboard.caller = caller;
            string         hash    = MD5Core.GetHashString(string.Format("{0}.{1}.{2}", GameId, DeviceId, 0));
            string         uri     = string.Format(URI_PREFIX + "?act=remove&gameid={0}&deviceid={1}&score={2}&hash={3}", GameId, DeviceId, 0, hash);
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);

            request.BeginGetResponse(removeScoreCallback, request);
        }
コード例 #18
0
        public String GetPlaintText(String request)
        {
            var hashString = MD5Core.GetHashString(Encoding.UTF8.GetBytes(request));

            var plaintText =
                new String((from c in hashString.ToCharArray() where char.IsLetterOrDigit(c) select c).ToArray());

            return(plaintText);
        }
コード例 #19
0
        protected override string onPrepareDataFilePath(IsolatedStorageFile currentIsolatedStorage)
        {
            if (!currentIsolatedStorage.DirectoryExists(StorageIO.getImagePath()))
            {
                currentIsolatedStorage.CreateDirectory(StorageIO.getImagePath());
            }
            string hashString = MD5Core.GetHashString(this.mImgInfo.strThumbnail + Util.getNowMilliseconds());

            return(StorageIO.getImagePath() + "/" + hashString + "_recv.jpg");
        }
コード例 #20
0
        private string hashString(string _value)
        {
            // MD5CryptoServiceProvider x = new MD5CryptoServiceProvider();
            byte[] data = System.Text.Encoding.UTF8.GetBytes(_value);//ASCII
            //data = x.ComputeHash(data);
            string ret = "";

            ret = MD5Core.GetHashString(data).ToLower();
            //ret = "";
            //for (int i = 0; i < data.Length; i++) ret += data[i].ToString("x2").ToLower();
            return(ret);
        }
コード例 #21
0
ファイル: MD5Core.cs プロジェクト: Makzz90/VKClient_re
 public static string GetHashString(string input, Encoding encoding)
 {
     if (input == null)
     {
         throw new ArgumentNullException("input", "Unable to calculate hash over null input data");
     }
     if (encoding == null)
     {
         throw new ArgumentNullException("encoding", "Unable to calculate hash over a string without a default encoding. Consider using the GetHashString(string) overload to use UTF8 Encoding");
     }
     return(MD5Core.GetHashString(encoding.GetBytes(input)));
 }
コード例 #22
0
        public void UpdateTile(String area)
        {
            if (mAreaWeatherList == null || mAreaWeatherList.Count <= 0)
            {
                return;
            }

            if (mAreaWeatherList.ContainsKey(area))
            {
                if (mAreaWeatherList.ContainsKey(area))
                {
                    List <RichListItem> items = mAreaWeatherList[area];
                    if (items.Count == 3)
                    {
                        String strAreaMD5 = MD5Core.GetHashString(area);
                        String strBackgroundImageFileName     = String.Format("Fore_{0}.jpg", strAreaMD5);
                        String strBackBackgroundImageFileName = String.Format("Back_{0}.jpg", strAreaMD5);
                        String strBackgroundImageFilePath     = GetShareToTileAlbumCoverPath(strBackgroundImageFileName);
                        String strBackBackgroundImageFilePath = GetShareToTileAlbumCoverPath(strBackBackgroundImageFileName);

                        Boolean IsRefreshOK = false;
                        try
                        {
                            CreateTileBackgroundFile(items[0], strBackgroundImageFilePath);
                            CreateTileBackBackgroundFile(items[1], items[2], strBackBackgroundImageFilePath);
                            IsRefreshOK = true;
                        }
                        catch (Exception)
                        {
                        }

                        if (IsRefreshOK)
                        {
                            String    strTileKeyWord   = String.Format(Constants.TILE_NAVIGATION_KEYWORD, area);
                            String    strNavigationURL = String.Format(Constants.TILE_NAVIGATION_URL, area);
                            ShellTile tile             = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(strTileKeyWord));

                            if (tile != null)
                            {
                                // 更新圖片
                                StandardTileData NewTileData = new StandardTileData
                                {
                                    BackgroundImage     = new Uri("isostore:/" + strBackgroundImageFilePath, UriKind.Absolute),
                                    BackBackgroundImage = new Uri("isostore:/" + strBackBackgroundImageFilePath, UriKind.Absolute)
                                };
                                tile.Update(NewTileData);
                            }
                        }
                    }
                }
            }
        }
コード例 #23
0
        private void ContextMenuSetTile_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            temp = (MenuItem)sender;
            AreaWeatherListItem item = (AreaWeatherListItem)temp.DataContext;

            // 檢查 scheduledAgent 是否活著…若是死的就試著喚醒…
            if (UtilityHelper.CheckScheduledAgent())
            {
                if (item != null)
                {
                    if (!"".Equals(item.Area))
                    {
                        #region 若沒有此動態磚就加入,過程發生錯誤也沒關係,Agent 會幫忙把資訊補回來
                        String    strTileKeyWord = String.Format(Constants.TILE_NAVIGATION_KEYWORD, item.Area);
                        ShellTile tile           = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(strTileKeyWord));
                        if (tile == null)
                        {
                            String strAreaMD5 = MD5Core.GetHashString(item.Area);
                            String strBackgroundImageFileName     = String.Format("Fore_{0}.jpg", strAreaMD5);
                            String strBackBackgroundImageFileName = String.Format("Back_{0}.jpg", strAreaMD5);
                            String strBackgroundImageFilePath     = UtilityHelper.GetShareToTileAlbumCoverPath(strBackgroundImageFileName);
                            String strBackBackgroundImageFilePath = UtilityHelper.GetShareToTileAlbumCoverPath(strBackBackgroundImageFileName);
                            String strNavigationURL = String.Format(Constants.TILE_NAVIGATION_URL, item.Area);

                            try
                            {
                                StandardTileData NewTileData = new StandardTileData
                                {
                                    BackgroundImage     = new Uri("isostore:/" + strBackgroundImageFilePath, UriKind.Absolute),
                                    BackBackgroundImage = new Uri("isostore:/" + strBackBackgroundImageFilePath, UriKind.Absolute)
                                };
                                ShellTile.Create(new Uri(strNavigationURL, UriKind.Relative), NewTileData);
                            }
                            catch (Exception)
                            {
                            }
                        }
                        #endregion

                        // 加入此地區的動態磚
                        TileService.Instance.UpdateTile(item.Area);
                    }
                }
            }
            else
            {
                // 開不了…提示
                MessageBox.Show("您的裝置拒絕 TW Weather 啟動背景作業。\n請先至系統設定頁開啟 TW Weather 的背景作業權限,否則動態磚將會更新失敗。");
            }
        }
コード例 #24
0
        public static void GetRank(ILeaderboardCaller caller)
        {
            Leaderboard.caller = caller;
            if (Score == 0)
            {
                caller.OnGetRankSuccess(-1);
                return;
            }
            string         hash        = MD5Core.GetHashString(string.Format("{0}.{1}.{2}", GameId, DeviceId, Score));
            string         uri         = string.Format(URI_PREFIX + "?act=myrank&gameid={0}&deviceid={1}&score={2}&hash={3}", GameId, DeviceId, Score, hash);
            HttpWebRequest rankRequest = (HttpWebRequest)HttpWebRequest.Create(uri);

            rankRequest.BeginGetResponse(getRankCallback, rankRequest);
        }
コード例 #25
0
        public bool doSceneSendAppMsg(string toUsername, int source, string xmlstr)
        {
            AppMsgInfo info = AppMsgMgr.ParseAppXml(xmlstr);

            if (info == null)
            {
                //Log.e("NetSceneSendAppMsg", "invalid AppMsgInfo, msg.strMsg = " + this.mAppMsg.strMsg);
                return(false);
            }
            base.beginBuilder();
            base.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(0);
            AppMsg.Builder builder = AppMsg.CreateBuilder();
            builder.AppId = info.appid;
            uint result = 0;

            builder.SdkVersion = uint.TryParse(info.sdkVer, out result) ? result : 0;
            builder.ToUserName = toUsername;
            info.fromUserName  = AccountMgr.curUserName;
            //if (info.fromUserName != AccountMgr.curUserName)
            //{
            //    Log.e("NetSceneSendAppMsg", "invalid from username = "******"appmsg") ?? "";
            if (info.showtype == 2)
            {
                //builder.Content = builder.Content + AppMsgMgr.getXmlNodeString(this.mAppMsg.strMsg, "ShakePageResult");
                builder.Content = builder.Content;
            }
            if (string.IsNullOrEmpty(builder.Content))
            {
                Log.e("NetSceneSendAppMsg", "invalid appmsgBuilder.Content = " + builder.Content);
                return(false);
            }
            builder.CreateTime  = (uint)Util.getNowSeconds();
            builder.ClientMsgId = MD5Core.GetHashString(toUsername + Util.getNowMilliseconds());;
            byte[] inBytes = null;//StorageIO.readFromFile(ChatMsgMgr.getMsgThumbnail(this.mAppMsg));
            if (inBytes != null)
            {
                builder.Thumb = Util.toSKBuffer(inBytes);
            }
            builder.Source           = (int)source;
            base.mBuilder.Msg        = builder.Build();
            base.mSessionPack.mCmdID = 0x6b;
            base.endBuilder();
            return(true);
        }
コード例 #26
0
        public static void SubmitScore(int score, string username, ILeaderboardCaller caller)
        {
            Leaderboard.caller = caller;
            UserName           = username;
            if (Score < score)
            {
                Score = score;
            }
            string         hash    = MD5Core.GetHashString(string.Format("{0}.{1}.{2}", GameId, DeviceId, score));
            string         uri     = string.Format(URI_PREFIX + "?act=submit&gameid={0}&deviceid={1}&score={2}&hash={3}&name={4}", GameId, DeviceId, Score, hash, UserName);
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);

            request.BeginGetResponse(submitScoreCallback, request);
            SettingHelper.SaveSetting();
        }
コード例 #27
0
        public string GetSignature(Dictionary <string, string> parameters)
        {
            string result = string.Empty;

            IOrderedEnumerable <KeyValuePair <string, string> > data = parameters.OrderBy(x => x.Key);

            foreach (var s in data)
            {
                result += s.Key + s.Value;
            }

            result += CoreViewModel.Instance.ApiKeys.LastFmSecret;
            result  = MD5Core.GetHashString(Encoding.UTF8.GetBytes(result));

            return(result);
        }
コード例 #28
0
        //获取设备id
        private string getDeviceID()
        {
            try
            {
                byte[] input = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
                if ((input != null) && (input.Length > 0))
                {
                    return(MD5Core.GetHashString(input));
                }
            }
            catch (Exception exception)
            {
                DebugTool.Log(exception);
            }

            return("0000000000");
        }
コード例 #29
0
        public async Task <string> userShout(string user, string message)
        {
            string requestString = "api_key" + apiKey + "message" + message +
                                   "methoduser.shout" + "sk" + sk + "user" + user + "96bd810a71249530b5f3831cd09f43d1";

            string api_sig = MD5Core.GetHashString(requestString);
            var    request = new LFCRequest();

            request.addParameter("method", "user.shout");
            request.addParameter("user", user);
            request.addParameter("message", message);
            request.addParameter("api_key", apiKey);
            request.addParameter("api_sig", api_sig);
            request.addParameter("sk", sk);
            var response = await request.execute();

            return(response);
        }
コード例 #30
0
        public static async Task <bool> CheckUserAuthAsync(string id, string pw)
        {
            var collection = Mongo.GetAccountDBCollection <DBUserAccountInfo>(COLLECTION_NAME);
            var userInfo   = await Task.Run(() => collection.FindOne(Query.EQ("_id", id)));

            if (userInfo == null)
            {
                return(false);
            }

            string hashPW = MD5Core.GetHashString(pw);

            if (userInfo.PW != hashPW)
            {
                return(false);
            }

            return(true);
        }