本文整理汇总了C#中System.String.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# String.GetHashCode方法的具体用法?C# String.GetHashCode怎么用?C# String.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String
的用法示例。
在下文中一共展示了String.GetHashCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
/// <summary>
/// Returns a specific Stopwatch if it exists.
/// </summary>
/// <param name="identifier">Identifing the used Stopwatch.</param>
/// <returns>The specified stopwatch.</returns>
public Stopwatch this[String identifier]
{
get
{
if (!_stopwatches.ContainsKey(identifier.GetHashCode())) return null;
return _stopwatches[identifier.GetHashCode()];
}
set
{
if (value == null) throw new NullReferenceException("Value is null.");
_stopwatches[identifier.GetHashCode()] = value;
}
}
示例2: Activity
public Activity(String code, String name)
{
this.hash = code.GetHashCode();
this.code = code;
this.name = name;
ACTIVITY_POOL.RegisterActivity(this);
}
示例3: rfc4122
public static string rfc4122(String seed)
{
int oldSeed = Random.seed;
Random.seed = seed.GetHashCode();
string uuid = rfc4122();
Random.seed = oldSeed;
return uuid;
}
示例4: GenerateID
/// <summary>
/// generates a unique vactionRequestID
/// </summary>
/// <param name="EmployeeID"> the EmployeeID of the creator</param>
/// <returns>vactionRequestID</returns>
public ulong GenerateID(String EmployeeID)
{
DateTime moment = DateTime.Now;
long timestamp = moment.Ticks - new DateTime(1970, 1, 1).Ticks;
long iDHash = EmployeeID.GetHashCode();
ulong vactionRequestID = (ulong)((timestamp & 0x0000FFFFFFFFFFFF) | (iDHash << 48));
return vactionRequestID;
}
示例5: StorageKey
public StorageKey(Guid uid, String key)
{
UID = uid;
UniqueKey = key;
FragmentID = key.GetHashCode();
}
示例6: checkPassword
public static Boolean checkPassword(String password, Int32 passwordHash)
{
Boolean ret;
/* Implement function */
ret = (passwordHash == password.GetHashCode());
/* */
return ret;
}
示例7: generatePasswordHash
public static Int32 generatePasswordHash(String password)
{
Int32 ret;
/* Implement function */
ret = password.GetHashCode();
/* */
return ret;
}
示例8: getCaptchaFromSiDdos
private Bitmap getCaptchaFromSiDdos(String domen, String sidDdos)
{
string localFilename = Directory.GetCurrentDirectory() + @"\" + sidDdos.GetHashCode() + ".jpg";
using (WebClient client = new WebClient())
{
client.DownloadFile(domen + "agent.php?a=code&sid=" + sidDdos, localFilename);
Bitmap image = new Bitmap(localFilename);
return image;
}
}
示例9: IsExist
public Boolean IsExist(String fileName)
{
if (String.IsNullOrEmpty(fileName) == true) return false;
int hash = Math.Abs(fileName.GetHashCode());
hash = hash % 10000;
int bucket1 = hash / 100;
int bucket2 = hash % 100;
String fullPath = Path.Combine(BaseDir, bucket1.ToString(), bucket2.ToString(), fileName);
return File.Exists(fullPath);
}
示例10: createPic
public String createPic(String base64Code, String format)
{
try
{
//use standard 3 letter suffix
if (format == "jpeg")
{
format = "jpg";
}
//get hash code of this specific image as its file name, ensuring duplicate image won't be created
String fileName = base64Code.GetHashCode().ToString();
fileName = fileName + "." + format;
//generate full path of the image
String fileFullPath = storePath + "\\" + fileName;
//if image doesn't exist, create it
if (!File.Exists(fileFullPath))
{
byte[] arr = Convert.FromBase64String(base64Code);
MemoryStream ms = new MemoryStream(arr, 0, arr.Length);
ms.Write(arr, 0, arr.Length);
Image image = Image.FromStream(ms, true);
switch (format)
{
case "jpg":
image.Save(fileFullPath, ImageFormat.Jpeg);
break;
case "gif":
image.Save(fileFullPath, ImageFormat.Gif);
break;
case "png":
image.Save(fileFullPath, ImageFormat.Png);
break;
case "bmp":
image.Save(fileFullPath, ImageFormat.Bmp);
break;
default:
break;
}
ms.Close();
}
//return file name for replacing the original "src" in _resultXML
return fileName;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error");
return "Error Happened.";
}
}
示例11: authenticate
/// <summary>
/// Function used to authenticate the specified user
/// </summary>
/// <param name="userName">user identifier </param>
/// <param name="password">user password</param>
/// <returns>User: authenticated, null: not authenticated</returns>
public User authenticate(String userName, String password)
{
User user = null;
String hashedPassword = password.GetHashCode().ToString("x");
//validar password
user = (from u in context.Users
where u.UserName == userName
&& u.Password == hashedPassword
select u).FirstOrDefault();
return user;
}
示例12: Build
public String Build(String[] s)
{
if (s[0] != "1" && s[0] != "2" && s[0] != "3" && s[0] != "4" && s[0] != "5" && s[0] != "6" )
{
throw new ArgumentException("Protokolltyp " + s[0] + "in param[0] ist nicht definiert!");
}
String ret = "";
for (int i = 0; i < s.Length; i++)
{
ret += s[i] + "@@@";
}
ret += s.GetHashCode();
return ret;
}
示例13: insertUser
//public Boolean isAuthorized(String userName, String permissionName)
//{
//}
public void insertUser(String userName, String completeName , String password, long userID )
{
var newUser = new User();
newUser.Id = (int)IdentifierGenerator.NewId();
newUser.IdSession = SessionManager.getSessionIdentifier();
newUser.UserName = userName;
newUser.CompleteName = completeName;
newUser.Password = password.GetHashCode().ToString("x");
newUser.IdUserRelation = userID;
context.Users.Add(newUser);
context.SaveChanges();
}
示例14: Resolve
public void Resolve(String name, bool ip4Only)
{
this.m_name = name;
int hash = name.GetHashCode();
if (hash < 0)
hash = -hash;
hash = hash % 55536;
hash += 10000;
try {
Address = new IPEndPoint(IPAddress.Loopback, hash);
} catch (Exception ex) {
throw new ArgumentException("",ex);
}
}
示例15: ConnectionKey
public ConnectionKey(String username, String password)
{
this.username = username;
this.password = password;
this.hash = 31;
if (!String.IsNullOrEmpty(username))
{
hash += username.GetHashCode();
}
hash *= 31;
if (!String.IsNullOrEmpty(password))
{
hash += password.GetHashCode();
}
}