bugScheme Untergrund Library - Bugs: bug #4373, Please add a base64-encode-string

 
 

bug #4373: Please add a base64-encode-string

Submitted by:  Lionel Elie Mamane <lmamane>
Submitted on:  Sat 19 Jul 2003 06:22:42 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Michel Schinz <michel-schinz>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 21 Nov 2003 10:30:38 AM UTC, comment #3:

Ok, your example makes sense. I added function base64-encode-string. Thanks.

Michel Schinz <michel-schinz>
Project MemberIn charge of this item.
Fri 21 Nov 2003 10:08:31 AM UTC, comment #2:

I think it should be part of the library.

The case where I needed it was:

I was having problems with the SMTP authentication of an SMTP server I admin. I wanted to go through the protocol by myself, with "telnet". Some authentication schemes BASE64-encode the password and other login information sent over the wire, so to test them, I had to BASE64-encode them.

The most convenient thing to do was to type (base64-encode-string "the password")

While technically, the standard allows for more or less arbitrary binary data, the authentication parameters tend to contain only typable characters (alphanum and punctuation and the like), because some human has to provide them to the program. Typing them on the keyboard is the most natural way to do that :)

Lionel Elie Mamane <lmamane>
Project Member
Sat 01 Nov 2003 07:07:44 PM UTC, comment #1:

base64-encode-string can actually be defined in one line, using string ports. Here is how:

(define (base64-encode-string string . rest)
(apply base64-encode-port (make-string-input-port string) rest))

However, if you still think that it should be part of the library, please tell me, I will include it. My main motivation for not including it in the original version was that usually one encodes binary data with base64, not strings, but maybe I didn't think about some cases.

Michel Schinz <michel-schinz>
Project MemberIn charge of this item.
Sat 19 Jul 2003 06:22:42 PM UTC, original submission:

This one works for me:

(define (base64-encode-string str . rest)
(let ((len (string-length str)) (pos 0))
(apply base64-encode-internal
(lambda ()
(if (< pos len)
(let ((byte (string-ref str pos)))
(set! pos (+ pos 1))
(char->ascii byte))
eof-object))
rest)))

Lionel Elie Mamane <lmamane>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 3 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Fri 21 Nov 2003 10:31:18 AM UTCmichel-schinzOpen/ClosedOpen=>(Error - Not Found)
Fri 21 Nov 2003 10:30:38 AM UTCmichel-schinzStatusNone=>(Error - Not Found)
Sat 01 Nov 2003 06:40:45 PM UTCmichel-schinzAssigned toNone=>NA

Back to the top


Powered by Savane 3.1-cleanup1