hash

Create a multidimesional key of hash from array?

与世无争的帅哥 提交于 2020-01-19 04:08:50
问题 I want to create a multidimensional %hash from the @array . Suppose @array is like my @array=(1,2,3,4,5); I want to assign @array last value as final value to multidimensional %hash i.e %hash=( 1=>{ 2=> { 3=> { 4=>5 } } } ) Which means $hash{1}{2}{3}{4}=5; I want to do it in something like: for my $i (0..$#array){ #push $i as key until second last element and assign last element as value } Note : The @array may be of any size, Just I want to assign last element of @array as value to the keys

PHP & Hash / Fragment Portion of URL

牧云@^-^@ 提交于 2020-01-19 03:28:26
问题 I am trying to find a way to save the hash portion of a url and as a PHP variable. This idea is a bit kooky, but bear with me... I'd like to extract the "location" fragment from the following URL and save it as a PHP variable. http://www.example.com/#location However, discussion at this link indicates that the fragment of a URL is only reachable through JavaScript. But would it be possible to create a link where the fragment is duplicated in the URL, parsed by PHP, and then removed by mod

PHP & Hash / Fragment Portion of URL

半世苍凉 提交于 2020-01-19 03:28:13
问题 I am trying to find a way to save the hash portion of a url and as a PHP variable. This idea is a bit kooky, but bear with me... I'd like to extract the "location" fragment from the following URL and save it as a PHP variable. http://www.example.com/#location However, discussion at this link indicates that the fragment of a URL is only reachable through JavaScript. But would it be possible to create a link where the fragment is duplicated in the URL, parsed by PHP, and then removed by mod

ConcurrentHashMap 详解

故事扮演 提交于 2020-01-18 23:55:21
一、 JDK7下的 CurrentHashMap 在JDK1.7版本中,ConcurrentHashMap的数据结构是由一个Segment数组和多个HashEntry组成,主要实现原理是实现了锁分离的思路解决了多线程的安全问题。Segment数组的意义就是将一个大的table分割成多个小的table来进行加锁,也就是上面的提到的锁分离技术,而每一个Segment元素存储的是 HashEntry数组+链表,这个和HashMap的数据存储结构一样。 如下图所示: ConcurrentHashMap 与HashMap和Hashtable 最大的不同在于:put和 get 两次Hash到达指定的HashEntry,第一次hash到达Segment,第二次到达Segment里面的Entry, 然后在遍历entry链表. ConcurrentHashMap完全允许多个读操作并发进行,读操作并不需要加锁。 1. 初始化 ConcurrentHashMap的初始化是会通过位运算来初始化Segment的大小,用ssize来表示,源码如下所示: private static final int DEFAULT_CONCURRENCY_LEVEL = 16; private void writeObject(java.io.ObjectOutputStream s) throws java.io

分布式均匀算法--hash性一致算法--hash slot(转)

故事扮演 提交于 2020-01-18 08:02:32
目录   1、redis cluster介绍   2、最老土的hash算法和弊端(大量缓存重建)   3、一致性hash算法(自动缓存迁移)+虚拟节点(自动负载均衡)     不用遍历 --》 hash算法: 缓存位置= hash(key)%n     新增/减少 节点 --》缓存位置失效--》hash环     hash环 节点少--》数据倾斜--》添加虚拟节点   4、redis cluster的hash slot算法 分布式寻址算法 hash 算法(大量缓存重建) 一致性 hash 算法(自动缓存迁移)+ 虚拟节点(自动负载均衡) redis cluster 的 hash slot 算法 1、redis cluster介绍  redis cluster   (1)自动将数据进行分片,每个master上放一部分数据   (2)提供内置的高可用支持,部分master不可用时,还是可以继续工作的  在redis cluster架构下,每个redis要放开两个端口号,比如一个是6379,另外一个就是加10000的端口号,比如16379  16379端口号是用来进行节点间通信的,也就是cluster bus的东西,集群总线。cluster bus的通信,用来进行故障检测,配置更新,故障转移授权  cluster bus用了另外一种二进制的协议,主要用于节点间进行高效的数据交换

HTTPS 原理解析

∥☆過路亽.° 提交于 2020-01-18 07:59:28
HTTPS 原理解析 一 前言   在说HTTPS之前先说说什么是HTTP,HTTP就是我们平时浏览网页时候使用的一种协议。HTTP协议传输的数据都是未加密的,也就是明文的,因此使用HTTP协议传输隐私信息非常不安全。为了保证这些隐私数据能加密传输,于是网景公司设计了SSL(Secure Sockets Layer)协议用于对HTTP协议传输的数据进行加密,从而就诞生了HTTPS。SSL目前的版本是3.0,被IETF(Internet Engineering Task Force)定义在RFC 6101中,之后IETF对SSL 3.0进行了升级,于是出现了TLS(Transport Layer Security) 1.0,定义在RFC 2246。实际上我们现在的HTTPS都是用的TLS协议,但是由于SSL出现的时间比较早,并且依旧被现在浏览器所支持,因此SSL依然是HTTPS的代名词,但无论是TLS还是SSL都是上个世纪的事情,SSL最后一个版本是3.0,今后TLS将会继承SSL优良血统继续为我们进行加密服务。目前TLS的版本是1.2,定义在RFC 5246中,暂时还没有被广泛的使用 () 概念可参考百科 http://baike.baidu.com/link?url=M8pBu1j_22f0PW6izvAOCTjhepyRcT320U9LDmjyzb586OYS

Ruby combining hashes in an array based on one hash value

旧时模样 提交于 2020-01-17 12:25:52
问题 I have an array of hashes that looks like: [ {"id"=>1, "name"=>"Batman", "net_worth"=>100, "vehicles"=>2}, {"id"=>1, "name"=>"Batman", "net_worth"=>100, "vehicles"=>2}, {"id"=>2, "name"=>"Superman", "net_worth"=>100, "vehicles"=>2}, {"id"=>3, "name"=>"Wonderwoman", "net_worth"=>100, "vehicles"=>2} ] I'd like to combine hashes based on the id value while preserving it, preserve the name, and sum the net_worth and vehicles values. So the final array would look like: [ {"id"=>1, "name"=>"Batman"

md5/hash on vb6?

本小妞迷上赌 提交于 2020-01-17 07:38:07
问题 I'm making a program that has a login. Is there any way to encrypt the normal password so that it can't be read in the data base? I've done a trick but I'm not content with it. What I did was to get the first, mid, and last char only and convert each char into ascii. Is there a way to convert all the text into ascii or something like md5/hash in php? I'm really sorry about this thing, I haven't mentioned that my project is a VB6 project. 回答1: Don't use MD5 to store hashed passwords! See stuff

Sha-1 hash fixed point

社会主义新天地 提交于 2020-01-17 03:08:44
问题 how hard is it to find x where sha1(x) = x? where x is the form of 'c999303647068a6abaca25717850c26c9cd0d89c' i think the fact that there are sha1 collisions make this possible, but, how easy (or hard) is it to find an example? 回答1: Read Cryptanalysis of SHA-1 on Wikipedia. There's more information than you need on that article and its references combined. Edit: how hard is it to find x where sha1(x) = x? Such an attack is known as a preimage attack and finding such an x is usually much

Using hashCat with a RAR file?

試著忘記壹切 提交于 2020-01-17 02:19:48
问题 I'm pretty stumped, is it actually possible to use hashcat for a RAR file? The forum says "yes" and points to a sample... They appear to be calling: ./oclHashcat64.bin -m 12500 hash -w 3 -a 3 ha?l?l?l?l?l So far, so good.. So I go grab jtr and run rar2john, which gives me; test.rar:$RAR3$*1*1234561234561234*e1111111*22222222*33333333*0*/home/test.rar*77*33:1::testClip.wmv I've tried every permutation of this in place of the 'hash' in the command, but I always get Line-length exception Has