Parcourir la source

Merge branch 'release' of https://tree.clementinecomputing.com/clementinecomputing/popufare into release

clementinecomputing il y a 4 ans
Parent
commit
27a666c456
2 fichiers modifiés avec 35 ajouts et 11 suppressions
  1. 12 3
      busunit/passdb/fareqr.c
  2. 23 8
      server/qr_generator/qr_mag.html

+ 12 - 3
busunit/passdb/fareqr.c

@@ -395,18 +395,27 @@ int fareqr_lookup_seed_secret(char *seedfn, char *pub, char *priv) {
         tok0_ptr = buf;
         tok1_ptr = strchr(buf, ' ');
         if (tok1_ptr) {
+
+          // tie off the tok0_ptr (public key) for use later
+          //
           *tok1_ptr = '\0';
-          tok1_ptr++;
+
+          // start our private key ptr at the start of the
+          // private key, skipping over whitespace
+          //
+          do {
+            tok1_ptr++;
+          } while ( (*tok1_ptr) && ((*tok1_ptr) == ' ') );
 
 
-          // Cechk it against our supplied 'pulbic' key
+          // Check it against our supplied 'pulbic' key
           //
           if (strcmp(pub, tok0_ptr)==0) {
 
             // If we've found it, copy it over to the `priv`
             // above and return
             //
-            for (i=0; tok1_ptr[i]; i++) {
+            for (i=0; tok1_ptr[i] && (tok1_ptr[i] != ' '); i++) {
               priv[i] = tok1_ptr[i];
             }
             priv[i]='\0';

+ 23 - 8
server/qr_generator/qr_mag.html

@@ -6,6 +6,7 @@
     <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
     <script type="text/javascript" src="jquery.min.js"></script>
     <script type="text/javascript" src="qrcode.js"></script>
+    <script type="text/javascript" src="crypto-js.js"></script>
   </head>
 
   <body>
@@ -17,21 +18,35 @@
 
     <script type="text/javascript">
 
+      function base64ToHex(str) {
+        const raw = atob(str);
+        let result = '';
+        for (let i = 0; i < raw.length; i++) {
+          const hex = raw.charCodeAt(i).toString(16);
+          result += (hex.length === 2 ? hex : '0' + hex);
+        }
+        return result;
+      }
+
+function base64ToArrayBuffer(base64) {
+    var binary_string = window.atob(base64);
+    var len = binary_string.length;
+    var bytes = new Uint8Array(len);
+    for (var i = 0; i < len; i++) {
+        bytes[i] = binary_string.charCodeAt(i);
+    }
+    return bytes.buffer;
+}
 
       var qrcode = new QRCode(document.getElementById("qrcode"), {
         width : 400,
-        height : 400
+        height : 400,
+        correctLevel: QRCode.CorrectLevel.L
       });
 
       function makeCode () {		
         var elText = document.getElementById("text");
-        
-        if (!elText.value) {
-          alert("Input a text");
-          elText.focus();
-          return;
-        }
-        
+        if (!elText.value) { return; }
         qrcode.makeCode(elText.value);
       }