コード例 #1
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));
            }
        }
コード例 #2
0
ファイル: MD5Core.cs プロジェクト: Makzz90/VKClient_re
 internal static byte[] GetHashFinalBlock(byte[] input, int ibStart, int cbSize, ABCDStruct ABCD, long len)
 {
     byte[] input1 = new byte[64];
     byte[] bytes  = BitConverter.GetBytes(len);
     Array.Copy((Array)input, ibStart, (Array)input1, 0, cbSize);
     input1[cbSize] = (byte)128;
     if (cbSize < 56)
     {
         Array.Copy((Array)bytes, 0, (Array)input1, 56, 8);
         MD5Core.GetHashBlock(input1, ref ABCD, 0);
     }
     else
     {
         MD5Core.GetHashBlock(input1, ref ABCD, 0);
         byte[] input2 = new byte[64];
         Array.Copy((Array)bytes, 0, (Array)input2, 56, 8);
         MD5Core.GetHashBlock(input2, ref ABCD, 0);
     }
     byte[] numArray = new byte[16];
     Array.Copy((Array)BitConverter.GetBytes(ABCD.A), 0, (Array)numArray, 0, 4);
     Array.Copy((Array)BitConverter.GetBytes(ABCD.B), 0, (Array)numArray, 4, 4);
     Array.Copy((Array)BitConverter.GetBytes(ABCD.C), 0, (Array)numArray, 8, 4);
     Array.Copy((Array)BitConverter.GetBytes(ABCD.D), 0, (Array)numArray, 12, 4);
     return(numArray);
 }
コード例 #3
0
        private void UpdateItemsAsync()
        {
            _isGettingContacts = true;
            //IsWorking = true;
            var contactIds = string.Join(",", Items.Select(x => x.Index).OrderBy(x => x));
            var hash       = MD5Core.GetHash(contactIds);
            var hashString = BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();

            MTProtoService.GetContactsAsync(new TLString(hashString),
                                            result =>
            {
                _isGettingContacts = false;

                //IsWorking = false;
                if (result is TLContactsNotModified)
                {
                    return;
                }

                InsertContacts(((TLContacts)result).Users, false);
            },
                                            error =>
            {
                _isGettingContacts = false;
                //IsWorking = false;
            });
        }
コード例 #4
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);
        }
コード例 #5
0
 public void TestLong()
 {
     foreach (var tuple in LongTestData)
     {
         Assert.AreEqual(tuple.Item2, MD5Core.GetHashString(tuple.Item1));
     }
 }
コード例 #6
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);
        }
コード例 #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 <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);
            }
        }
コード例 #9
0
 /// <summary>
 /// Encodes the input as a MD5 hash
 /// </summary>
 /// <param name="input">
 /// The input we want encoded <see cref="System.String"/>
 /// </param>
 /// <returns>
 /// The MD5 hash encoded result of input <see cref="System.String"/>
 /// </returns>
 public string CreateMD5Hash(string input)
 {
             #if !UNITY_FLASH && !UNITY_WP8 && !UNITY_METRO
     // Gets the MD5 hash for input
     MD5    md5  = new MD5CryptoServiceProvider();
     byte[] data = Encoding.UTF8.GetBytes(input);
     byte[] hash = md5.ComputeHash(data);
     // Transforms as hexa
     string hexaHash = "";
     foreach (byte b in hash)
     {
         hexaHash += String.Format("{0:x2}", b);
     }
     // Returns MD5 hexa hash as string
     return(hexaHash);
             #elif UNITY_WP8 || UNITY_METRO
     byte[] data = Encoding.UTF8.GetBytes(input);
     byte[] hash = MD5Core.GetHash(data);
     // Transforms as hexa
     string hexaHash = "";
     foreach (byte b in hash)
     {
         hexaHash += String.Format("{0:x2}", b);
     }
     // Returns MD5 hexa hash as string
     return(hexaHash);
             #else
     return(MD5Wrapper.Md5Sum(input));
             #endif
 }
コード例 #10
0
        protected override void HashCore(byte[] array, int ibStart, int cbSize)
        {
            int startIndex       = ibStart;
            int totalArrayLength = _dataSize + cbSize;

            if (totalArrayLength >= 64)
            {
                Array.Copy(array, startIndex, _data, _dataSize, 64 - _dataSize);
                // Process message of 64 bytes (512 bits)
                MD5Core.GetHashBlock(_data, ref _abcd, 0);
                startIndex       += 64 - _dataSize;
                totalArrayLength -= 64;
                while (totalArrayLength >= 64)
                {
                    Array.Copy(array, startIndex, _data, 0, 64);
                    MD5Core.GetHashBlock(array, ref _abcd, startIndex);
                    totalArrayLength -= 64;
                    startIndex       += 64;
                }
                _dataSize = totalArrayLength;
                Array.Copy(array, startIndex, _data, 0, totalArrayLength);
            }
            else
            {
                Array.Copy(array, startIndex, _data, _dataSize, cbSize);
                _dataSize = totalArrayLength;
            }
            _totalLength += cbSize;
        }
コード例 #11
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));
        }
コード例 #12
0
        private int GetPortFromAddress(IPAddress address)
        {
            byte[] addr;
            int    port;

            if (address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetworkV6)
            {
                addr = new byte[address.GetAddressBytes().Length + 12];
                Buffer.BlockCopy(address.GetAddressBytes(), 0, addr, 12, address.GetAddressBytes().Length);
                addr[10] = (byte)0xFF;
                addr[11] = (byte)0xFF;
            }
            else
            {
                addr = address.GetAddressBytes();
            }

            byte[] hash = MD5Core.GetHash(addr);

            uint part0 = hash[0];
            uint part1 = hash[1];
            uint part2 = hash[2];
            uint part3 = hash[3];

            port  = (int)((part0 + part3) << 8);
            port  = (int)(port + part1 + part2);
            port &= 0xFFFF;

            if (port < 1024)
            {
                port += 1024;
            }

            return(port);
        }
コード例 #13
0
    public static byte[] GetHash(byte[] input)
    {
        if (null == input)
        {
            throw new System.ArgumentNullException("input", "Unable to calculate hash over null input data");
        }

        //Intitial values defined in RFC 1321
        ABCDStruct abcd = new ABCDStruct();

        abcd.A = 0x67452301;
        abcd.B = 0xefcdab89;
        abcd.C = 0x98badcfe;
        abcd.D = 0x10325476;

        //We pass in the input array by block, the final block of data must be handled specialy for padding & length embeding
        int startIndex = 0;

        while (startIndex <= input.Length - 64)
        {
            MD5Core.GetHashBlock(input, ref abcd, startIndex);
            startIndex += 64;
        }
        // The final data block.
        return(MD5Core.GetHashFinalBlock(input, startIndex, input.Length - startIndex, abcd, (Int64)input.Length * 8));
    }
コード例 #14
0
            public byte[] TransformFinalBlock()
            {
                ThrowNotSupportedExceptionForNonThreadSafeMethod();

                totalLength += remainingCount;
                return(MD5Core.GetHashFinalBlock(remainingBuffer, 0, remainingCount, abcdStruct, (Int64)totalLength * 8));
            }
コード例 #15
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);
 }
コード例 #16
0
        public string getApiSig()
        {
            string requestString = "api_key" + apiKey +
                                   "methodauth.getmobilesession" + "password" +
                                   password + "username" + username + secretApiKey;

            return(MD5Core.GetHashString(requestString));
        }
コード例 #17
0
            public byte[] Compute20(byte[] bytes)
            {
#if !SILVERLIGHT
                return(ComputeHash(SHA1.Create(), bytes));
#else
                return(MD5Core.GetHash(bytes));
#endif
            }
コード例 #18
0
ファイル: ServerHash.cs プロジェクト: stvoidmain/ravendb
        private static byte[] GetHash(byte[] bytes)
        {
#if NETFX_CORE
            return(MD5Core.GetHash(bytes));
#else
            return(Encryptor.Current.Hash.Compute16(bytes));
#endif
        }
コード例 #19
0
        public static String ConvertPasswordToMD5(String plainPasswd)
        {
            string MD5Passwd = "";

            byte[] result = MD5Core.GetHash(plainPasswd);
            MD5Passwd = BinaryToHex(result);
            return(MD5Passwd.ToLower());
        }
コード例 #20
0
ファイル: MD5Core.cs プロジェクト: Makzz90/VKClient_re
 public static string GetHashString(byte[] input)
 {
     if (input == null)
     {
         throw new ArgumentNullException("input", "Unable to calculate hash over null input data");
     }
     return(BitConverter.ToString(MD5Core.GetHash(input)).Replace("-", ""));
 }
コード例 #21
0
ファイル: DigestToken.cs プロジェクト: jessenic/7Pass
        private static string GetHash(string text)
        {
            var bytes = MD5Core.GetHash(text);

            return(BitConverter.ToString(bytes)
                   .Replace("-", string.Empty)
                   .ToLowerInvariant());
        }
コード例 #22
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));
 }
コード例 #23
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());
        }
コード例 #24
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 =>
                {
                });
            }
        }
コード例 #25
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);
        }
コード例 #26
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);
 }
コード例 #27
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);
 }
コード例 #28
0
ファイル: MD5Core.cs プロジェクト: 07101994/BlueMarin
        public static string ToMD5(this String @this)
        {
            if (@this == null)
            {
                return(null);
            }

            return(MD5Core.GetHashString(@this));
        }
コード例 #29
0
 private static String _getOpenUDID()
 {
     _lastError = OpenUDIDErrors.None;
     if (_cachedValue == null)
     {
         _cachedValue = MD5Core.GetHashString(_getOldDeviceUniqueId());
     }
     return(_cachedValue);
 }
コード例 #30
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);
        }