digest

AngularJS: Fire an event immediately after $scope.$digest

瘦欲@ 提交于 2019-12-03 00:31:35
In my AngularJS app, there's several points at which I want to wait for a $scope to be processed into the DOM, and then run some code on it, like a jquery fadeIn, for example. Is there a way to listen for a digestComplete message of some sort? My current method is, immediately after setting whatever $scope variables I want rendered, use setTimeout with a delay of 0 ms, so that it will let the scope finish digesting, and then run the code, which works perfectly. Only problem is, I very occasionally see the DOM render before that setTimeout returns. I'd like a method that is guaranteed to fire

Creating an md5 hash of a number, string, array, or hash in Ruby

僤鯓⒐⒋嵵緔 提交于 2019-12-02 21:04:03
I need to create a signature string for a variable in Ruby, where the variable can be a number, a string, a hash, or an array. The hash values and array elements can also be any of these types. This string will be used to compare the values in a database (Mongo, in this case). My first thought was to create an MD5 hash of a JSON encoded value, like so: (body is the variable referred to above) def createsig(body) Digest::MD5.hexdigest(JSON.generate(body)) end This nearly works, but JSON.generate does not encode the keys of a hash in the same order each time, so createsig({:a=>'a',:b=>'b'}) does

Example of SOAP request authenticated with WS-UsernameToken

故事扮演 提交于 2019-12-02 16:44:53
I'm trying to authenticate a SOAP request using WS-UsernameToken spec, but the target device is always denying access. My non-working request looks like this. (The password I'm trying to hash is system .) <?xml version="1.0" encoding="UTF-8"?> <Envelope xmlns="http://www.w3.org/2003/05/soap-envelope"> <Header> <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <UsernameToken> <Username>root</Username> <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">EVpXS/7yc/vDo+ZyIg+cc0fWdMA=<

Different results with Java's digest versus external utilities

六眼飞鱼酱① 提交于 2019-12-02 14:11:08
I have written a simple Java class to generate the hash values of the Windows Calculator file. I am using Windows 7 Professional with SP1 . I have tried Java 6.0.29 and Java 7.0.03 . Can someone tell me why I am getting different hash values from Java versus (many!) external utilities and/or websites? Everything external matches with each other, only Java is returning different results. import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; import

How to post http request using digest authentication with libcurl

僤鯓⒐⒋嵵緔 提交于 2019-12-02 00:09:29
问题 I'm trying to perform a post request and I'm trying to do it with the digest authentication. with libcurl , I set the options: curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); curl_easy_setopt(curl_handle, CURLOPT_USERPWD, "username:password"); before setting all the other option (post, url and everything). The server closes my connection and I think that no digest is made. I just don't know how to automatically obtain the challenge-response behaviour of the digest. If I set

Rails compiles assets both with and without md5 hash, why?

烈酒焚心 提交于 2019-12-01 02:37:42
I'm relatively new to RoR and I'm curious about why Rails compiles assets both with and without md5 hash for production? I run bundle exec rake assets:clean then bundle exec rake assets:precompile My production.rb file: MyApp::Application.configure do # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) config.serve_static_assets = false # Compress

PDF Signature digest

南笙酒味 提交于 2019-11-30 21:37:54
I have a quick question about calculating the digest of a PDF document to use for a digital signature (somewhat related to one of my earlier questions, I'm trying to figure out why you would need to know a client's certificate to create the correct digest). In Adobe's documentation about the PDF format the following is specified: A byte range digest shall be computed over a range of bytes in the file, that shall be indicated by the ByteRange entry in the signature dictionary. This range should be the entire file, including the signature dictionary but excluding the signature value itself (the

Lightweight 8 byte hash function algorithm

半世苍凉 提交于 2019-11-30 19:09:50
I need to extract an 8 byte digest from a variable length string so I'm looking for such an algorithm that I will implement in c/c++. That will be part of a digital signature procedure on a microcontroller, so it has to be: writable in few lines of code, since the firmware has to be kept as little as possible; low in resource consumption, expecially ram (preferably less than 100 bytes); strong enough that changing a single character at any point of the string would change the overall digest. I took a look at existing algorithms such as crc64 but they seems to be too heavy for my platform. As

Glassfish Security - jdbcRealm: How to configure login with SHA-256 digest

て烟熏妆下的殇ゞ 提交于 2019-11-30 10:52:01
问题 I use jdbcRealm for security in my glassfish v3.0.1 b22. It is set up so that it use the USER table inside my database for authentication by following this blog: http://blogs.oracle.com/foo/entry/mort_learns_jdbc_realm_authentication. I got it working fine, if I leave the digest algorithm as plain text. However when i try to use SHA-256 for digest algorithm, it stop working. What I did is specify in Glassfish - Security - Realm - jdbcRealm - digest that I want SHA-256 (I just type SHA-256

What does [“string”].pack('H*') mean?

筅森魡賤 提交于 2019-11-30 07:28:47
问题 I need to translate some Ruby code to JavaScript and came across the following function: def sha1_hex(h) Digest::SHA1.hexdigest([h].pack('H*')) end What exactly does [h].pack('H*') mean in this context? How would it translate to JavaScript? 回答1: It interprets the string as hex numbers, two characters per byte, and converts it to a string with the characters with the corresponding ASCII code: ["464F4F"].pack('H*') # => "FOO", 0x46 is the code for 'F', 0x4F the code for 'O' For the opposite