Source

ecrypto / sha1-old.el

Diff from to

File sha1-old.el

     ;; slightly hairier math when writing the length into len-string.
 
     (dotimes (idx 4)
-      (aset len-string (+ 4 idx) (logand ?\xff
+      (aset len-string (+ 4 idx) (logand #xff
 				   (ash length (+ -21 (* 8 idx))))))
 
     (sha1-vector
   (let ((a (car val))
 	(b (cdr val)))
     ;; only three cases ever occur
-    (cond ((= shift 1) (cons (logand ?\xffff (logior (ash a 1) (ash b -15)))
-			     (logand ?\xffff (logior (ash b 1) (ash a -15)))))
-	  ((= shift 5) (cons (logand ?\xffff (logior (ash a 5) (ash b -11)))
-			     (logand ?\xffff (logior (ash b 5) (ash a -11)))))
+    (cond ((= shift 1) (cons (logand #xffff (logior (ash a 1) (ash b -15)))
+			     (logand #xffff (logior (ash b 1) (ash a -15)))))
+	  ((= shift 5) (cons (logand #xffff (logior (ash a 5) (ash b -11)))
+			     (logand #xffff (logior (ash b 5) (ash a -11)))))
 	  ;; shift = 30, which is a swap and a shift by 14
-	  (t (cons (logand ?\xffff (logior (ash b 14) (ash a -2)))
-		   (logand ?\xffff (logior (ash a 14) (ash b -2))))))))
+	  (t (cons (logand #xffff (logior (ash b 14) (ash a -2)))
+		   (logand #xffff (logior (ash a 14) (ash b -2))))))))
 
 (defsubst sha1+ (&rest args)
   ;; since we only use 16 bits, there's enough room to just add
   ;; without carry checks for each add.
   (let* ((lo (apply #'+ (mapcar #'cdr args)))
 	 (hi (+ (ash lo -16) (apply #'+ (mapcar #'car args)))))
-    (cons (logand ?\xffff hi)
-	  (logand ?\xffff lo))))
+    (cons (logand #xffff hi)
+	  (logand #xffff lo))))
 
 (defsubst sha1-logxor4 (a b c d)
   (cons (logxor (car a) (car b) (car c) (car d))
 
 (defun sha1-vector (vec)
   ;; initialize the chaining variables
-  (let ((a (cons ?\x6745 ?\x2301))
-	(b (cons ?\xefcd ?\xab89))
-	(c (cons ?\x98ba ?\xdcfe))
-	(d (cons ?\x1032 ?\x5476))
-	(e (cons ?\xc3d2 ?\xe1f0))
+  (let ((a (cons #x6745 #x2301))
+	(b (cons #xefcd #xab89))
+	(c (cons #x98ba #xdcfe))
+	(d (cons #x1032 #x5476))
+	(e (cons #xc3d2 #xe1f0))
 	(w (make-vector 80 0))
 	(v-offset 0))
 
 	(dotimes (count 20)
 ;;	  (insert (format "%s %s %s %s %s\n"
 ;;			  a b c d e))
-	  (sha1-rewrite sha1-f1 '(?\x5a82 . ?\x7999)))
+	  (sha1-rewrite sha1-f1 '(#x5a82 . #x7999)))
 
 	(dotimes (count 20)
-	  (sha1-rewrite sha1-f2&4 '(?\x6ed9 . ?\xeba1)))
+	  (sha1-rewrite sha1-f2&4 '(#x6ed9 . #xeba1)))
 
 	(dotimes (count 20)
-	  (sha1-rewrite sha1-f3 '(?\x8f1b . ?\xbcdc)))
+	  (sha1-rewrite sha1-f3 '(#x8f1b . #xbcdc)))
 
 	(dotimes (count 20)
-	  (sha1-rewrite sha1-f2&4 '(?\xca62 . ?\xc1d6)))
+	  (sha1-rewrite sha1-f2&4 '(#xca62 . #xc1d6)))
 
 	(setq a (sha1+ AA a)
 	      b (sha1+ BB b)