hash

Hash randomization in Perl 5

放肆的年华 提交于 2019-12-22 04:19:12
问题 When Perl 5.8.1 came out it added hash randomization. When Perl 5.8.2 came out, I thought, it removed hash randomization unless an environment variable ( PERL_HASH_SEED ) was present. It now seems as if I am gravely mistaken as PERL_HASH_SEED=$SEED perl -MData::Dumper -e 'print Dumper{map{$_,1}"a".."z"}' Always kicks back the same key ordering regardless of the value of $SEED . Did hash randomization go completely away, am I doing something wrong, or is this a bug? 回答1: See Algorithmic

add a hash with javascript to url without scrolling page?

99封情书 提交于 2019-12-22 04:06:34
问题 add a hash to url without scrolling page? with javascript i open page i scroll down i click link that adds a hash (maybe with a value #test) (example: http://www.example.com/#test) the page MUST not scroll back to the top. how can this be done? note: just checking if it's possible to disable the movement even if there is some tag with id="test" so far the return false; works fine (to support people without javascript), and also to avoid the presence of the id's in the html, but it is not a

Why does Enumerable#find/#detect return an Array even when called on an Hash?

你说的曾经没有我的故事 提交于 2019-12-22 04:01:19
问题 The documentation for Enumerable#find/#detect says: find(ifnone = nil) { |obj| block } → obj or nil find(ifnone = nil) → an_enumerator Passes each entry in enum to block . Returns the first for which block is not false. If no object matches, calls ifnone and returns its result when it is specified, or returns nil otherwise. However, when it is called on the Hash, the result has changed the type to Array instead of the original Hash. Is it some implementation fault or some historical

Python, get base64-encoded MD5 hash of an image object

拥有回忆 提交于 2019-12-22 03:58:11
问题 I need to get a base64-encoded MD5 hash of an object, where the object is an image stored as a file, fname. I've tried this: def get_md5(fname): hash = hashlib.md5() with open(fname) as f: for chunk in iter(lambda: f.read(4096), ""): hash.update(chunk) return hash.hexdigest().encode('base64').strip() However, I don't think this is right because it returns a string with too many characters. My understanding is that it needs to be 24 characters long. I get

Number of distinct sums from non-empty groupings of (possibly very large) lists

旧街凉风 提交于 2019-12-22 01:23:33
问题 Assume that you are given a set of coin types (maximum 20 distinct types) and from each type you have maximum 10^5 instances, such that the total number of all the coins in your list is maximum 10^6. What is the number of distinct sums you can make from non-empty groupings of these coins. for example, you are given the following lists: coins=[10, 50, 100] quantity=[1, 2, 1] which means you have 1 coin of 10, and 2 coins of 50, and 1 coin of 100. Now the output should be possibleSums(coins,

Ansible vault password in group_vars not detected [duplicate]

我只是一个虾纸丫 提交于 2019-12-22 00:59:24
问题 This question already has an answer here : Ansible with “Alternative Directory Layout” and using vaults (1 answer) Closed 2 years ago . I am trying to use ansible-vault to secure a single Windows login password. I do not want to place hte password as plain text in my windows.yml file (see below) and so I am trying to use ansible-vault to secure/encrypt this password. I have this directory structure: myansiblehome - windows_manage - group_vars - windows.yml - vault - hosts - win_playbook.yml

How do I generate an (almost) unique hash ID for objects?

一世执手 提交于 2019-12-22 00:38:33
问题 How can I get an ID for my objects that makes it easy to distinguish it from others? class MyClass { private String s; private MySecondClass c; private Collection<someInterface> coll; // ..many more public Result calculate() { /* use all field values recursively to calculate the result */ /* takes considerable amount of time. Implemented */ return result; } public String hash() { /* use all field values recursively to generate a unique identifier */ // ????? } calculate() usually takes ~40

Ruby/Rails - Add records to an object with each loop iteration / Object vs Arrays

∥☆過路亽.° 提交于 2019-12-22 00:28:36
问题 I'm trying to figure out how to add records to an existing object for each iteration of a loop. I'm having a hard time discovering the difference between an object and an array. I have this @events = Event.find(1) @loops = Choices.find(:all, :limit => 5) #so loop for 5 instances of choice model for loop in @loops @events = Event.find(:all,:conditions => ["event.id = ?", loop.event_id ]) end I'm trying to add a new events to the existing @events object based on the id of whatever the loop

How to validate Symfony2 sha512 passwords using nodejs

僤鯓⒐⒋嵵緔 提交于 2019-12-21 23:37:33
问题 I need to be able to validate in node some password which were generated and stored using Symfony2 with sha512 encoding. I can retrieve the hash and the salt just fine but when using crypto I cannot manage to generate a hash using the salt which matches the one stored in the database. Symfony security.yml security: encoders: "FOS\UserBundle\Model\UserInterface": sha512 Hash stored in DB 6zxwRZc4EPXKxQes9avs0ZyCRFkC4dtpXrT983ML8VLvv9WhRnAi282bwuFuj3LHPQBGmqD1BfCLDUXGdHIjZQ== Salt stored in DB

Scrypt hash algorithm for password hashing in Swift 3.0 (iOS)

Deadly 提交于 2019-12-21 22:16:18
问题 I am trying to find a library to implement password hashing(with salt) using Scrypt algorithm. My question is similar to one already asked in stackoverflow (Hash password in Swift application) I have found following two libraries in swift and objective c respectively but the hash string generated from these is not matching with the one generated at server. Swift-Sodium (https://github.com/jedisct1/swift-sodium) NAChloride (https://github.com/gabriel/NAChloride) Can someone please help in