本文整理汇总了C#中Hash类的典型用法代码示例。如果您正苦于以下问题:C# Hash类的具体用法?C# Hash怎么用?C# Hash使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hash类属于命名空间,在下文中一共展示了Hash类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Init
public void Init()
{
SignerPublicKey = new Hash();
BallotHash = new Hash();
Signature = new Hash();
LedgerCloseSequence = 0;
}
开发者ID:dipamchang,项目名称:tnetd-open,代码行数:7,代码来源:BallotAgreeResponse.cs
示例2: Authorization
/// <summary>
/// Метод реализующий авторизацию пользователя. Принимает 2 параметра: логин и пароль. Задаёт метод щифрования и устанавливает соединение с БД, передавая принятые параметры.
/// Возрашает Boolean соединения.
/// </summary>
/// <param name="user">Логин</param>
/// <param name="pass">Пароль</param>
/// <returns>Успех или крах авторизации</returns>
public static bool Authorization(string user, string pass)
{
//Задаём алгоритм хэширования пасса
HashType = Hash.SHA1;
MySqlDataReader dataReaderTemp = MySQL.UserAut(user, pass);
while (dataReaderTemp.Read())
{
Id = dataReaderTemp.GetInt32("id_user");
Login = dataReaderTemp.GetString("login_user");
Role = dataReaderTemp.GetString("role");
}
if (!dataReaderTemp.HasRows)
{
MySQL.connection.Close();
return false;
}
bool toReturn = false;
switch (HashType)
{
case Hash.SHA1:
if (sha1(pass) == dataReaderTemp.GetString("pass_user"))
toReturn = true;
break;
case Hash.MD5:
if (md5(pass) == dataReaderTemp.GetString("pass_user"))
toReturn = true;
break;
}
MySQL.connection.Close();
MemoryManagement.FlushMemory();
return toReturn;
}
开发者ID:ruhex,项目名称:ais,代码行数:41,代码来源:User.cs
示例3: HeaderHash
public HeaderHash(Hash hash = null)
{
_names = new Dictionary<string, string>();
hash = hash ?? new Hash();
hash.Each(pair => this[pair.Key] = pair.Value);
}
开发者ID:kevinswiber,项目名称:NRack,代码行数:7,代码来源:HeaderHash.cs
示例4: Compile
public bool Compile(string path, string compileToFilePath = null)
{
using (FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read))
{
foreach (var kv in _config.CodeTemplates)
{
var templateStr = kv.Key;
var exportPath = kv.Value;
// 生成代码
var template = Template.Parse(templateStr);
var topHash = new Hash();
topHash["NameSpace"] = _config.NameSpace;
var files = new List<Hash>();
topHash["Files"] = files;
var hash = DoCompiler(path, stream, compileToFilePath);
files.Add(hash);
if (!string.IsNullOrEmpty(exportPath))
File.WriteAllText(exportPath, template.Render(topHash));
}
}
return true;
}
开发者ID:dannisliang,项目名称:CosmosTable,代码行数:28,代码来源:Compiler.cs
示例5: Decode
public static Hash Decode(IByteReader stream)
{
Hash decodedHash = new Hash();
int Hashsize = 32;
decodedHash.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)Hashsize);
return decodedHash;
}
开发者ID:FihlaTV,项目名称:csharp-stellar-base,代码行数:7,代码来源:Hash.cs
示例6:
public LeafDataType this[Hash hash]
{
get
{
return Values[hash];
}
}
开发者ID:dipamchang,项目名称:tnetd-open,代码行数:7,代码来源:FlatNodeStore.cs
示例7: Initialize
public static Hash/*!*/ Initialize([NotNull]BlockParam/*!*/ defaultProc, Hash/*!*/ self) {
Assert.NotNull(self, defaultProc);
self.DefaultProc = defaultProc.Proc;
self.DefaultValue = null;
return self;
}
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:HashOps.cs
示例8: NetworkPacket
public NetworkPacket(Hash publicKey_Src, PacketType type, byte[] Data)
{
PublicKeySource = publicKey_Src;
Type = type;
this.Data = Data;
Token = new Hash();
}
开发者ID:dipamchang,项目名称:tnetd-open,代码行数:7,代码来源:NetworkPacket.cs
示例9: GetAsync
public async Task<Package> GetAsync(long id, SemanticVersion version, Hash hash)
{
var key = prefix + id.ToString() + "/" + version.ToString();
var ms = new MemoryStream();
using (var blob = await bucket.GetAsync(key))
{
using (var data = blob.Open())
{
await data.CopyToAsync(ms).ConfigureAwait(false);
}
}
ms.Position = 0;
var secret = SecretKey.Derive(password, hash.Data);
var protector = new AesProtector(secret); // dispose?
var stream = protector.DecryptStream(ms);
#region Verify the hash
var computedHash = Hash.ComputeSHA256(stream, true);
if (computedHash != hash)
{
throw new IntegrityException(hash.Data, computedHash.Data);
}
#endregion
return ZipPackage.FromStream(stream, false);
}
开发者ID:carbon,项目名称:Platform,代码行数:35,代码来源:ProtectedPackageStore.cs
示例10: NodeSocketData
public NodeSocketData(Hash PublicKey, int ListenPort, string IP, string Name)
{
this.PublicKey = PublicKey;
this.ListenPort = ListenPort;
this.IP = IP;
this.Name = Name;
}
开发者ID:dipamchang,项目名称:tnetd-open,代码行数:7,代码来源:GlobalConfiguration.cs
示例11: RemoteReferenceData
public RemoteReferenceData(string name, Hash hash)
{
Verify.Argument.IsNeitherNullNorWhitespace(name, "name");
_name = name;
_hash = hash;
}
开发者ID:Kuzq,项目名称:gitter,代码行数:7,代码来源:RemoteReferenceData.cs
示例12: findElementGivenHash
/* This function (for internal use only) locates an element in an
** hash table that matches the given key. The hash for this key has
** already been computed and is passed as the 4th parameter.
*/
static HashElem findElementGivenHash(
Hash pH, /* The pH to be searched */
string pKey, /* The key we are searching for */
int nKey, /* Bytes in key (not counting zero terminator) */
u32 h /* The hash for this key. */
)
{
HashElem elem; /* Used to loop thru the element list */
int count; /* Number of elements left to test */
if ( pH.ht != null && pH.ht[h] != null )
{
_ht pEntry = pH.ht[h];
elem = pEntry.chain;
count = (int)pEntry.count;
}
else
{
elem = pH.first;
count = (int)pH.count;
}
while ( count-- > 0 && ALWAYS( elem ) )
{
if ( elem.nKey == nKey && elem.pKey.Equals( pKey, StringComparison.InvariantCultureIgnoreCase ) )
{
return elem;
}
elem = elem.next;
}
return null;
}
开发者ID:taxilian,项目名称:some_library,代码行数:35,代码来源:hash_c.cs
示例13: Exists
public bool Exists(Hash hash)
{
if (files.ContainsKey(hash)) return true;
if (CheckAndAddOneFile(hash)) return true;
return false;
}
开发者ID:Jamanno,项目名称:Zero-K-Infrastructure,代码行数:7,代码来源:Pool.cs
示例14: RemoteBranchData
public RemoteBranchData(string name, Hash sha1)
{
Verify.Argument.IsNeitherNullNorWhitespace(name, "name");
_name = name;
_sha1 = sha1;
}
开发者ID:Kuzq,项目名称:gitter,代码行数:7,代码来源:RemoteBranchData.cs
示例15: Hash
public void Given_a_sequence_validation_transcoder_When_writen_to_the_transcoding_stream_Then_the_inner_stream_contains_the_previous_identifier_followed_by_the_data_written()
{
byte[] hashBytes = { 1, 2, 3, 4 };
const string TestText = "Test";
var hash = new Hash(hashBytes);
var previousEventHashReader = new PreviousEventHashReader(hash);
var sequenceValidationTranscodingStreamFactory = new SequenceValidationTranscodingStreamFactory(previousEventHashReader);
using (var innerStream = new MemoryStream())
using (var sequenceValidationTranscodingStream = sequenceValidationTranscodingStreamFactory.CreateTrancodingStream(innerStream))
{
var writer = new StreamWriter(sequenceValidationTranscodingStream);
writer.Write(TestText);
writer.Flush();
sequenceValidationTranscodingStream.Flush();
innerStream.Seek(0, SeekOrigin.Begin);
var hashBuffer = new byte[4];
innerStream.Read(hashBuffer, 0, 4);
var reader = new StreamReader(innerStream);
var actualText = reader.ReadToEnd();
CollectionAssert.AreEqual(hashBytes, hashBuffer);
Assert.AreEqual(TestText, actualText);
}
}
开发者ID:danielrbradley,项目名称:Event-Driven-Domain,代码行数:28,代码来源:TranscodingStreamTests.cs
示例16: Initialize
public void Initialize()
{
CoolHashFunctionByMe coolHash = new CoolHashFunctionByMe();
tableString = new Hash<string>(coolHash);
BoringStandartHashFunction boringHash = new BoringStandartHashFunction();
tableInt = new Hash<int>(boringHash);
}
开发者ID:GalinaSazonova,项目名称:2semester,代码行数:7,代码来源:HashTableTest.cs
示例17: CreateDefaultTagMapping
private static Hash CreateDefaultTagMapping(RubyContext/*!*/ context) {
Hash taggedClasses = new Hash(context.EqualityComparer);
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:array"), context.GetClass(typeof(RubyArray)));
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:exception"), context.GetClass(typeof(Exception)));
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:hash"), context.GetClass(typeof(Hash)));
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:object"), context.GetClass(typeof(object)));
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:range"), context.GetClass(typeof(Range)));
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:regexp"), context.GetClass(typeof(RubyRegex)));
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:string"), context.GetClass(typeof(MutableString)));
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:struct"), context.GetClass(typeof(RubyStruct)));
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:sym"), context.GetClass(typeof(SymbolId)));
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:symbol"), context.GetClass(typeof(SymbolId)));
taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:time"), context.GetClass(typeof(DateTime)));
taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:binary"), context.GetClass(typeof(MutableString)));
taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:bool#no"), context.FalseClass);
taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:bool#yes"), context.TrueClass);
taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:float"), context.GetClass(typeof(Double)));
taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:int"), context.GetClass(typeof(Integer)));
taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:map"), context.GetClass(typeof(Hash)));
taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:null"), context.NilClass);
taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:seq"), context.GetClass(typeof(RubyArray)));
taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:str"), context.GetClass(typeof(MutableString)));
taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:timestamp"), context.GetClass(typeof(DateTime)));
//Currently not supported
//taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:omap"), ec.GetClass(typeof()));
//taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:pairs"),// ec.GetClass(typeof()));
//taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:set"),// ec.GetClass(typeof()));
//taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:timestamp#ymd'"), );
return taggedClasses;
}
开发者ID:bclubb,项目名称:ironruby,代码行数:30,代码来源:RubyYaml.cs
示例18: FromDynamic
public static Hash FromDynamic(dynamic source)
{
var result = new Hash();
if (source != null)
{
if (source is ExpandoObject)
{
return Hash.FromDictionary((IDictionary<string, object>)source);
}
var type = (Type)source.GetType();
if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(type))
{
throw new NotImplementedException("I don't feel like coding this up right now; use a static type?");
}
PropertyInfo[] properties;
if (CachedStatics.ContainsKey(type))
{
properties = CachedStatics[type];
}
else
{
properties = type.GetProperties();
CachedStatics.Add(type, properties);
}
foreach (var property in properties)
{
result[property.Name] = property.GetValue(source, null);
}
}
return result;
}
开发者ID:ehsan-davoudi,项目名称:webstack,代码行数:31,代码来源:HashExtensions.cs
示例19: IsConnected
/// <summary>
/// Check whether the given PK is already connected.
/// </summary>
/// <param name="PublicKey"></param>
/// <returns></returns>
public bool IsConnected(Hash PublicKey)
{
if (IncomingConnections.ContainsKey(PublicKey))
{
return true;
}
else return false;
}
开发者ID:dipamchang,项目名称:tnetd-open,代码行数:13,代码来源:IncomingConnectionHander.cs
示例20: sqlite3HashInit
/*
** 2001 September 22
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This is the implementation of generic hash-tables
** used in SQLite.
*************************************************************************
** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
** C#-SQLite is an independent reimplementation of the SQLite software library
**
** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3
**
*************************************************************************
*/
//#include "sqliteInt.h"
//#include <assert.h>
/* Turn bulk memory into a hash table object by initializing the
** fields of the Hash structure.
**
** "pNew" is a pointer to the hash table that is to be initialized.
*/
static void sqlite3HashInit( Hash pNew )
{
Debug.Assert( pNew != null );
pNew.first = null;
pNew.count = 0;
pNew.htsize = 0;
pNew.ht = null;
}
开发者ID:pragmat1c,项目名称:coolstorage,代码行数:37,代码来源:hash_c.cs
注:本文中的Hash类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论