Skip to content

Commit

Permalink
added raw JSON processing for election hash
Browse files Browse the repository at this point in the history
  • Loading branch information
benadida committed Jan 5, 2009
1 parent 10c7c9a commit a42182f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 6 additions & 4 deletions helios/templates/vote.html
Expand Up @@ -50,9 +50,11 @@ <h3>Fingerprint: <span id="election_hash"></span></h3>
});
};

BOOTH.setup_election = function(election) {
BOOTH.setup_election = function(election, raw_json) {
BOOTH.election = HELIOS.Election.fromJSONObject(election);
BOOTH.election_hash = BOOTH.election.get_hash();

// compute the hash from the raw JSON
BOOTH.election_hash = b64_sha1(raw_json);

$('#election_hash').html(BOOTH.election_hash);

Expand Down Expand Up @@ -144,8 +146,8 @@ <h3>Fingerprint: <span id="election_hash"></span></h3>

BOOTH.load_and_setup_election = function() {
// the hash will be computed within the setup function call now
Helios.get_election({'election_id': "{{election.election_id}}"}, function(data) {
BOOTH.setup_election(data);
Helios.get_election({'election_id': "{{election.election_id}}"}, function(data, raw_json) {
BOOTH.setup_election(data, raw_json);
BOOTH.show_election();
});
};
Expand Down
3 changes: 2 additions & 1 deletion helios/utils.py
Expand Up @@ -28,7 +28,8 @@ def hash_b64(s):
removes the trailing "="
"""
hasher = sha.new(s)
return base64.b64encode(hasher.digest())[:-1]
result= base64.b64encode(hasher.digest())[:-1]
return result

def do_hmac(k,s):
"""
Expand Down
5 changes: 4 additions & 1 deletion static/helios-api.js
Expand Up @@ -34,7 +34,10 @@ _Helios_SameSite = Class.extend({
},

getJSON: function(url, callback) {
$.getJSON(API_PREFIX + url, callback);
// get the JSON manually so that the raw source is still accessible
$.get(API_PREFIX + url, function(json_str) {
callback($.secureEvalJSON(json_str), json_str);
});
},

get_election: function(params, callback) {
Expand Down

0 comments on commit a42182f

Please sign in to comment.