- (let ((a (car pack))
- (b (nth 1 pack))
- (c (nth 2 pack)))
- (concat
- (char-to-string (base64-num-to-char (ash a -2)))
- (if b
- (concat
- (char-to-string
- (base64-num-to-char (logior (ash (logand a 3) 4) (ash b -4))))
- (if c
- (concat
- (char-to-string
- (base64-num-to-char (logior (ash (logand b 15) 2) (ash c -6))))
- (char-to-string (base64-num-to-char (logand c 63)))
- )
- (concat (char-to-string
- (base64-num-to-char (ash (logand b 15) 2))) "=")
- ))
- (concat (char-to-string
- (base64-num-to-char (ash (logand a 3) 4))) "==")
- ))))
-
-(defun-maybe base64-encode-string (string)
- "Encode STRING to base64, and return the result."
- (let ((len (length string))
- (b 0)(e 57)
- dest)
+ (let ((buf (make-string 4 ?=)))
+ (aset buf 0 (base64-num-to-char (ash (car pack) -2)))
+ (if (nth 1 pack)
+ (progn
+ (aset buf 1 (base64-num-to-char
+ (logior (ash (logand (car pack) 3) 4)
+ (ash (nth 1 pack) -4))))
+ (if (nth 2 pack)
+ (progn
+ (aset buf 2 (base64-num-to-char
+ (logior (ash (logand (nth 1 pack) 15) 2)
+ (ash (nth 2 pack) -6))))
+ (aset buf 3 (base64-num-to-char
+ (logand (nth 2 pack) 63))))
+ (aset buf 2 (base64-num-to-char
+ (ash (logand (nth 1 pack) 15) 2)))))
+ (aset buf 1 (base64-num-to-char
+ (ash (logand (car pack) 3) 4))))
+ buf))
+
+(defun-maybe base64-encode-string (string &optional no-line-break)
+ "Base64-encode STRING and return the result.
+Optional second argument NO-LINE-BREAK means do not break long lines
+into shorter lines."
+ (let* ((len (length string))
+ (b 0)(e 57)
+ (dest ""))