hash

编码,加解密,签名,Hash

情到浓时终转凉″ 提交于 2020-01-24 10:14:36
工作中会听到各种各样是是而非的词汇,base64,url,sha256,rsa,hash等等,你能很好的分清这些词语吗? 这次我想把它们统一的整理说明下: 一: 编码 编码是信息从一种形式或格式转换为另一种形式的过程,所以他们是可逆的,不能称之为加密。 下面列举几个常见的(参考 编码那些事 ): html实体编码(10进制与16进制): 如把尖括号编码[ < ] -----> html十进制: < html十六进制:< javascript的八进制跟十六进制: 如把尖括号编码[ < ] -----> js八进制:\74 js十六进制:\x3c jsunicode编码: 如把尖括号编码[ < ] ----->jsunicode:\u003c url编码 base64编码: 如把尖括号编码[ < ] -----> url: %3C base64: PA== 你可以根据他们编码后的特征来快速分辨一个看上去毫无意义的字符是由什么编码转换过来的,并试试将其转换回去,百度有一个转化工具: xss编码转换工具 如下: 编码类型 特征(以什么特征字符开头) 以“<”字符为例 html实体编码10进制 &# &#60 html实体编码16进制 &#x &#x3c javascript的八进制 \ \74 javascript的十六进制 \x \x3c jsunicode编码 \u \u003c

javascript: completely remove top.location.hash?

时光总嘲笑我的痴心妄想 提交于 2020-01-24 08:51:21
问题 hey guys, quick question, I couldn't find anything useful on the web. if I have already a hash in my addressbar like e.g. domain.com#whatever and I call... top.location.hash = ""; the #wathever is transformed into domain.com# without anything. Is it possible to completely remove the hash? So there is no # left. Because if I call top.location.hash = ""; the page jumps to it's top, because a # is passed to the url. I want to prevent that. 回答1: top.location = '' should do that, but it will cause

javascript: completely remove top.location.hash?

为君一笑 提交于 2020-01-24 08:51:08
问题 hey guys, quick question, I couldn't find anything useful on the web. if I have already a hash in my addressbar like e.g. domain.com#whatever and I call... top.location.hash = ""; the #wathever is transformed into domain.com# without anything. Is it possible to completely remove the hash? So there is no # left. Because if I call top.location.hash = ""; the page jumps to it's top, because a # is passed to the url. I want to prevent that. 回答1: top.location = '' should do that, but it will cause

MD5 hash of a file in ABAP

不羁的心 提交于 2020-01-24 05:19:26
问题 I want to generate a MD5 hash of a text file in ABAP. I have not found any standard solution for generating it for a very big file. Function module CALCULATE_HASH_FOR_CHAR does not meet my requirements because it takes a string as an input parameter. Although it works for smaller files, in case of a for example 4 GB file one cannot construct such a big string. Does anybody know whether there is a standard piece of coding for doing that (my google efforts did not bring me anything) or maybe

How to remove duplicates in list of objects without __hash__

蹲街弑〆低调 提交于 2020-01-24 04:10:26
问题 I have a list of custom objects from which I want to remove the duplicates. Normally, you would do this by defining both __eq__ and __hash__ for your objects and then taking the set of the list of objects. I have defined __eq__ , but I can't figure out a good way to implement __hash__ such that it returns the same value for objects that are equal. More specifically, I have a class that is derived from the Tree class from the ete3 toolkit. I have defined two objects to be equal if their

How to make a hashcode(integer value) positive

谁都会走 提交于 2020-01-24 03:47:11
问题 int x = 10; int y = (x.hashcode() & 0xfffffff); How does the above code always make y positive ? Thanks! 回答1: x.hashcode() & 0xfffffff will turn the sign bit off. Math.abs is not used here because it returns negative if x.hashCode is equal to Integer.MIN_VALUE which will make the hashtable's array throw an ArrayOutOfBoundException which is not fun. From @JonSkeet comment: It doesn't just turn the sign bit off, it clears the next three bits as well . But with hash codes we deal with collisions

Undefined method 'to_h' on Ruby array

北慕城南 提交于 2020-01-24 02:09:05
问题 As per Ruby Array documentation, there is a method to_h which can be used to convert arrays to hash as long as each element of the array is another array of two elements. Example below from the same documentation p [[:foo, :bar], [1, 2]].to_h However, when I run the above code, I get this error: irb(main):001:0> p [[:foo, :bar], [1, 2]].to_h NoMethodError: undefined method `to_h' for [[:foo, :bar], [1, 2]]:Array from (irb):1 from E:/RubyInstall/bin/irb:12:in `<main>' irb(main):002:0> My Ruby

Redis的五大数据类型

徘徊边缘 提交于 2020-01-23 22:11:38
Redis支持5种数据类型:String(字符串),Hash(哈希),List(列表),Set(集合),Zset(有序集合) 1.String string是redis最基本的数据类型。一个key对应一个value。 string是二进制安全的,也就是说redis的string可以包含任何数据,比如jpg图片或者序列化的对象。 string类型是redis最基本的数据类型,string类型的值最大能存储512MB。 理解:string就像是Java中的map一样,一个key对应一个value 在以上实例中我们使用了 SET 和 GET 命令,键为 hello,值为world。 序号 命令及描述 1 SET key value 设置指定 key 的值 2 GET key获取指定 key 的值。 3 GETRANGE key start end返回 key 中字符串值的子字符 4 GETSET key value将给定 key 的值设为 value ,并返回 key 的旧值(old value)。 5 GETBIT key offset对 key 所储存的字符串值,获取指定偏移量上的位(bit)。 6 MGET key1 [key2…]获取所有(一个或多个)给定 key 的值。 7 SETBIT key offset value对 key 所储存的字符串值,设置或清除指定偏移量上的位

Compare md5 hashes of two files in python

吃可爱长大的小学妹 提交于 2020-01-23 10:49:05
问题 I want to compare hashes of two files. But no matter if files are different or not, even with different hashes comparison results True Here is the code: import hashlib hasher1 = hashlib.md5() afile1 = open('canvas.png', 'rb') buf1 = afile1.read() a = hasher1.update(buf1) print(str(hasher1.hexdigest())) hasher2 = hashlib.md5() afile2 = open('img5.png', 'rb') buf2 = afile2.read() b = hasher2.update(buf2) print(str(hasher2.hexdigest())) print(str(a) == str(b)) The output:

HashMap以及源码详解

天涯浪子 提交于 2020-01-23 10:28:30
HashMap实现接口以及继承类 实现了Map,Cloneable,Serializable接口,继承自AbstractMap类。 允许 null 值和 null 键,无序,不允许重复的集合 HashMap底层结构 HashMap底层接口是哈希表,也就是所谓的散列表。 简单介绍一下散列表,散列表的出现是为了解决链表和数组的缺陷,链表增删快,查询慢,数组查询快,增删慢。而散列表基于数组和列表进行演变,使得查询和增删的速度都非常快。 散列表的结构如下。 hashMap中的散列表是用数组+链表+红黑树去实现的 。 好的散列方式,会把数据散列到不同的位置,哪怕散列到同一个位置(这就是所谓的 哈希冲突 ),我们可以把它链起来变成链表(Java采用 链地址法 ),只要这个链表足够的短,我们就可以最快的查询数据,因为遍历两三个节点的时间非常短,近似于O(1)。 当链表足够长( 链表长度 >= 8)并且,节点足够多(节点数 >= 64)的时候,我们就把当前的链表变成红黑树。 (为什么节点 >=8 才变成红黑树,<=6变成链表? 因为根据泊松分布,当节点树大于等于 8 的时候,红黑树查询会比链表查询要快,而当节点数小于等于 6 的时候,会链表查询回避红黑树要快。7的时候是相当。) HashMap常用方法以及源码解析 简单介绍以下变量以及初始值: HashMap的最大容量(MAXIMUM