Commit 9fb8e1b4 authored by Stephane Glondu's avatar Stephane Glondu

Consistently add a newline character at the end of single-JSON files

parent bf304d25
{"description":"This is a test election.","name":"Test election","public_key":{"g":"14887492224963187634282421537186040801304008017743492304481737382571933937568724473847106029915040150784031882206090286938661464458896494215273989547889201144857352611058572236578734319505128042602372864570426550855201448111746579871811249114781674309062693442442368697449970648232621880001709535143047913661432883287150003429802392229361583608686643243349727791976247247948618930423866180410558458272606627111270040091203073580238905303994472202930783207472394578498507764703191288249547659899997131166130259700604433891232298182348403175947450284433411265966789131024573629546048637848902243503970966798589660808533","p":"16328632084933010002384055033805457329601614771185955389739167309086214800406465799038583634953752941675645562182498120750264980492381375579367675648771293800310370964745767014243638518442553823973482995267304044326777047662957480269391322789378384619428596446446984694306187644767462460965622580087564339212631775817895958409016676398975671266179637898557687317076177218843233150695157881061257053019133078545928983562221396313169622475509818442661047018436264806901023966236718367204710755935899013750306107738002364137917426595737403871114187750804346564731250609196846638183903982387884578266136503697493474682071","q":"61329566248342901292543872769978950870633559608669337131139375508370458778917","y":"14635082878118572654479921080249944001812293038810422159343238089595479240882299219246906288014009621479772514986719666120580071805977517512709536449580704387040200602501172760388225540685840285411774228955056554894778199335402959258815158862988075365242410449387167116346296481514414882426546780519521778091037414413395238663990507052035474205192620851516755387953867800973935897054822286902740224243498380336367014173394548123266419420289185997583417780349142205089750866593480737143971921887353321220824821931497851896766898090557192411266787781010869883177247094501345068629045693383217704047201748215908551010065"},"questions":[{"answers":["a","b","c","d","e"],"min":0,"max":1,"question":"Question 1?"},{"answers":["a","b","c","d","e","f"],"min":2,"max":3,"question":"Question 2?"},{"answers":["a","b","c"],"min":1,"max":1,"question":"Question 3?"}],"uuid":"6d122f00-2650-4de8-87de-30037a21f943","short_name":"test"}
\ No newline at end of file
{"description":"This is a test election.","name":"Test election","public_key":{"g":"14887492224963187634282421537186040801304008017743492304481737382571933937568724473847106029915040150784031882206090286938661464458896494215273989547889201144857352611058572236578734319505128042602372864570426550855201448111746579871811249114781674309062693442442368697449970648232621880001709535143047913661432883287150003429802392229361583608686643243349727791976247247948618930423866180410558458272606627111270040091203073580238905303994472202930783207472394578498507764703191288249547659899997131166130259700604433891232298182348403175947450284433411265966789131024573629546048637848902243503970966798589660808533","p":"16328632084933010002384055033805457329601614771185955389739167309086214800406465799038583634953752941675645562182498120750264980492381375579367675648771293800310370964745767014243638518442553823973482995267304044326777047662957480269391322789378384619428596446446984694306187644767462460965622580087564339212631775817895958409016676398975671266179637898557687317076177218843233150695157881061257053019133078545928983562221396313169622475509818442661047018436264806901023966236718367204710755935899013750306107738002364137917426595737403871114187750804346564731250609196846638183903982387884578266136503697493474682071","q":"61329566248342901292543872769978950870633559608669337131139375508370458778917","y":"14635082878118572654479921080249944001812293038810422159343238089595479240882299219246906288014009621479772514986719666120580071805977517512709536449580704387040200602501172760388225540685840285411774228955056554894778199335402959258815158862988075365242410449387167116346296481514414882426546780519521778091037414413395238663990507052035474205192620851516755387953867800973935897054822286902740224243498380336367014173394548123266419420289185997583417780349142205089750866593480737143971921887353321220824821931497851896766898090557192411266787781010869883177247094501345068629045693383217704047201748215908551010065"},"questions":[{"answers":["a","b","c","d","e"],"min":0,"max":1,"question":"Question 1?"},{"answers":["a","b","c","d","e","f"],"min":2,"max":3,"question":"Question 2?"},{"answers":["a","b","c"],"min":1,"max":1,"question":"Question 3?"}],"uuid":"6d122f00-2650-4de8-87de-30037a21f943","short_name":"test"}
......@@ -125,13 +125,6 @@ assert (tally = [|[| 1; 0; 1; 0; 0 |]; [|0; 4; 0; 4; 3; 0|]; [| 1; 1; 2 |]|]);;
let ( / ) = Filename.concat
let save_to filename writer x =
let oc = open_out filename in
let ob = Bi_outbuf.create_channel_writer oc in
writer ob x;
Bi_outbuf.flush_channel_writer ob;
close_out oc;;
let list_save_to filename writer xs =
let oc = open_out filename in
let ob = Bi_outbuf.create_channel_writer oc in
......
{"g":"14887492224963187634282421537186040801304008017743492304481737382571933937568724473847106029915040150784031882206090286938661464458896494215273989547889201144857352611058572236578734319505128042602372864570426550855201448111746579871811249114781674309062693442442368697449970648232621880001709535143047913661432883287150003429802392229361583608686643243349727791976247247948618930423866180410558458272606627111270040091203073580238905303994472202930783207472394578498507764703191288249547659899997131166130259700604433891232298182348403175947450284433411265966789131024573629546048637848902243503970966798589660808533","p":"16328632084933010002384055033805457329601614771185955389739167309086214800406465799038583634953752941675645562182498120750264980492381375579367675648771293800310370964745767014243638518442553823973482995267304044326777047662957480269391322789378384619428596446446984694306187644767462460965622580087564339212631775817895958409016676398975671266179637898557687317076177218843233150695157881061257053019133078545928983562221396313169622475509818442661047018436264806901023966236718367204710755935899013750306107738002364137917426595737403871114187750804346564731250609196846638183903982387884578266136503697493474682071","q":"61329566248342901292543872769978950870633559608669337131139375508370458778917"}
\ No newline at end of file
{"g":"14887492224963187634282421537186040801304008017743492304481737382571933937568724473847106029915040150784031882206090286938661464458896494215273989547889201144857352611058572236578734319505128042602372864570426550855201448111746579871811249114781674309062693442442368697449970648232621880001709535143047913661432883287150003429802392229361583608686643243349727791976247247948618930423866180410558458272606627111270040091203073580238905303994472202930783207472394578498507764703191288249547659899997131166130259700604433891232298182348403175947450284433411265966789131024573629546048637848902243503970966798589660808533","p":"16328632084933010002384055033805457329601614771185955389739167309086214800406465799038583634953752941675645562182498120750264980492381375579367675648771293800310370964745767014243638518442553823973482995267304044326777047662957480269391322789378384619428596446446984694306187644767462460965622580087564339212631775817895958409016676398975671266179637898557687317076177218843233150695157881061257053019133078545928983562221396313169622475509818442661047018436264806901023966236718367204710755935899013750306107738002364137917426595737403871114187750804346564731250609196846638183903982387884578266136503697493474682071","q":"61329566248342901292543872769978950870633559608669337131139375508370458778917"}
{"g":"2","p":"263","q":"131"}
\ No newline at end of file
{"g":"2","p":"263","q":"131"}
......@@ -79,13 +79,6 @@ let metadata =
(* Save to disk *)
let save_to filename writer x =
let oc = open_out filename in
let ob = Bi_outbuf.create_channel_writer oc in
writer ob x;
Bi_outbuf.flush_channel_writer ob;
close_out oc;;
open Serializable_j;;
save_to "election.json" (write_params write_ff_pubkey) params;;
save_to "metadata.json" write_metadata metadata;;
......@@ -97,6 +97,7 @@ module RunTrusteeKeygen (G : Election.FF_GROUP) = struct
let oc = open_out_gen [Open_wronly; Open_creat] perm filename in
let ob = Bi_outbuf.create_channel_writer oc in
writer ob thing;
Bi_outbuf.add_char ob '\n';
Bi_outbuf.flush_channel_writer ob;
close_out oc;
Printf.printf "%s key saved to %s\n%!" (String.capitalize kind) filename;
......
......@@ -43,13 +43,6 @@ let load_from_file of_string filename =
let read_number = Serializable_builtin_j.read_number
let save_to filename writer x =
let oc = open_out filename in
let ob = Bi_outbuf.create_channel_writer oc in
writer ob x;
Bi_outbuf.flush_channel_writer ob;
close_out oc;;
module type PARAMS = sig
val sk_file : string option
......
......@@ -187,3 +187,11 @@ let pbkdf2 ~prf ~salt ~iterations ~size password =
String.blit (one_iteration i) 0 result offset hLen;
done;
result
let save_to filename writer x =
let oc = open_out filename in
let ob = Bi_outbuf.create_channel_writer oc in
writer ob x;
Bi_outbuf.add_char ob '\n';
Bi_outbuf.flush_channel_writer ob;
close_out oc;;
......@@ -60,3 +60,5 @@ val pbkdf2 :
salt:string ->
iterations:int -> size:int ->
string -> string
val save_to : string -> (Bi_outbuf.t -> 'a -> unit) -> 'a -> unit
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment