hash

[Sql-Server]what data type to use for password salt and hash values and what length?

拜拜、爱过 提交于 2020-01-09 19:07:16
问题 I am generating salt and hash values from my passwords by using, string salt = CreateSalt(TxtPassword.Text.Length); string hash = CreatePasswordHash(TxtPassword.Text, salt); private static string CreateSalt(int size) { //Generate a cryptographic random number. RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] buff = new byte[size]; rng.GetBytes(buff); // Return a Base64 string representation of the random number. return Convert.ToBase64String(buff); } private static string

布隆过滤器

£可爱£侵袭症+ 提交于 2020-01-09 13:48:20
布隆过滤器 概念 布隆过滤器是概率型数据结构,由一个二进制向量和一系列随机映射函数组成。它可以用于检索一个元素是否在一个集合中。 实现过程 定义向量长度,并赋初值为0. 定义N个hash函数,并指定个数(1,N) 将需要存储的值经过n个hash计算得出的值作为key来修改向量的值(0=>1) 查询某个变量值是否不存在布隆过滤器里,只需要看它的hash值所对应的向量值是否为0,如果有一个为0,则一定不存在。如果全部为1,也不能证明该变量值一定在布隆过滤器里。 图例展示 初始化向量,并赋予初值为0 添加数据 检查数据 获取结论 只能判断这个数据完全不存在,但是不能完全判断其存在。 优势/劣势 优势 布隆过滤器存储空间和插入/查询时间都是常数。 Hash函数相互之间没有关系,方便由硬件并行实现。 布隆过滤器不需要存储元素本身,在某些对保密要求非常严格的场合有优势。 劣势 误差率 难以删除 删除在布隆过滤器的值 通过引用计数来实现,也就是说在hash值所对应的向量值采取引用计数方式,如果某个hash值是这个向量所对应的索引,则给它加1。如果要删除这个hash值所对应的向量的话,就看其索引值是否为0.如果不是0,就不能删除,否则可以删除。 删除整个布隆过滤器,重新在添加数据。 代码实现 安装 mmh3 pip install mmh3 安装bitarray pip install

Specializing std::hash to derived classes

你离开我真会死。 提交于 2020-01-09 11:40:13
问题 I have an abstract base class Hashable that classes that can be hashed derive from. I would now like to extend std::hash to all classes that derive from Hashable . The following code is supposed to do exactly that. #include <functional> #include <type_traits> #include <iostream> class Hashable { public: virtual ~Hashable() {} virtual std::size_t Hash() const =0; }; class Derived : public Hashable { public: std::size_t Hash() const { return 0; } }; // Specialization of std::hash to operate on

Hash syntax in Ruby [duplicate]

和自甴很熟 提交于 2020-01-09 10:37:03
问题 This question already has answers here : Is there any difference between the `:key => “value”` and `key: “value”` hash notations? (5 answers) Closed 2 years ago . According to The Well Grounded Rubyist : Ruby allows a special form of symbol representation in the hash-key position, with the colon after the symbol instead of before it and the hash separator arrow removed. In other words, this: hash = { :name => "David", :age => 49 } can also be written like this: hash = { name: David, age: 49 }

Hash syntax in Ruby [duplicate]

这一生的挚爱 提交于 2020-01-09 10:36:11
问题 This question already has answers here : Is there any difference between the `:key => “value”` and `key: “value”` hash notations? (5 answers) Closed 2 years ago . According to The Well Grounded Rubyist : Ruby allows a special form of symbol representation in the hash-key position, with the colon after the symbol instead of before it and the hash separator arrow removed. In other words, this: hash = { :name => "David", :age => 49 } can also be written like this: hash = { name: David, age: 49 }

SHA-256 hashes different between C# and Javascript

拟墨画扇 提交于 2020-01-09 10:26:51
问题 I am currently working on a project that will involve credit card swipes for admissions based on database rows. Like a will call system, the SHA-256 hash of the CC number must match the hash in the DB row in order to be considered the "proper pickup". However, because the box office system is based in the browser, the CC number on pickup must be hashed client-side, using Javascript, and then compared to the previously downloaded will call data. However when trying to hash the numbers, the

SHA-256 hashes different between C# and Javascript

会有一股神秘感。 提交于 2020-01-09 10:26:10
问题 I am currently working on a project that will involve credit card swipes for admissions based on database rows. Like a will call system, the SHA-256 hash of the CC number must match the hash in the DB row in order to be considered the "proper pickup". However, because the box office system is based in the browser, the CC number on pickup must be hashed client-side, using Javascript, and then compared to the previously downloaded will call data. However when trying to hash the numbers, the

hash() vs. crypt() function comparison

痴心易碎 提交于 2020-01-09 10:04:54
问题 I'm currently implementing a login system. I want to store the password and the salt in a database. Now I found out that there is a hash() and a crypt() function which seems to do the same (valid for SHA512). hash() is newer and seems to support more hashing alogrithms than crypt() . Or there any other differences I should know/care about? Edit: function generatePasswordHash($password){ $salt = base64_encode(mcrypt_create_iv(8)); $calculatedPasswordHash = crypt($password, '$1$' . $salt . '$')

How do I create an MD5 hash digest from a text file?

帅比萌擦擦* 提交于 2020-01-09 07:13:55
问题 Using C#, I want to create an MD5 hash of a text file. How can I accomplish this? Update: Thanks to everyone for their help. I've finally settled upon the following code - // Create an MD5 hash digest of a file public string MD5HashFile(string fn) { byte[] hash = MD5.Create().ComputeHash(File.ReadAllBytes(fn)); return BitConverter.ToString(hash).Replace("-", ""); } 回答1: Here's the routine I'm currently using. using System.Security.Cryptography; public string HashFile(string filePath) { using

Iterate over a deeply nested level of hashes in Ruby

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-09 06:20:53
问题 So I have a hash, and for each level of the hash, I want to store its key and value. The problem is, a value can be another hash array. Furthermore, that hash can contain key value pairs where the value is again another hash array, etc, etc. Also, I won't know how deeply nested each hash will be. To give an example: { :key1 => 'value1', :key2 => 'value2', :key3 => { :key4 => 'value4', :key5 => 'value5' }, :key6 => { :key7 => 'value7', :key8 => { :key9 => 'value9' } } } ..And so on. What I