1. -- requirements:
  2. -- + parent script "BASE64"
  3. --   http://valentin.dasdeck.com/lingo/binary_file_encoding/base64/d10/BASE64.LS
  4. -- + movie script "FILE_FILEIO" (D10- version):
  5. --   http://valentin.dasdeck.com/lingo/binary_file_interface/d10/FILE_FILEIO.LS
  6.  
  7. on test_encode  
  8.   ms = the milliseconds
  9.   b64 = script("base64_class").new()
  10.   binStr = file_get_bytes(_movie.path & "test.jpg")
  11.   --b64.setMimeHeader("test.jpg") -- save original filename in header (optional)
  12.   --b64.setMimeHeader("test.jpg", "image/jpeg") -- or save both original filename and mimetype (optional)
  13.   str = b64.base64Encode(binStr) -- optional: pass TRUE as 2. arg to slit in lines
  14.   ok = file_put_string(_movie.path & "test.jpg.b64", str)
  15.   put (the milliseconds-ms) && "ms"
  16. end
  17.  
  18. on test_decode
  19.   ms = the milliseconds
  20.   b64 = script("base64_class").new()
  21.   str = file_get_string(_movie.path & "test.jpg.b64")
  22.   binStr = b64.base64Decode(str)
  23.   ok = file_put_bytes(_movie.path & "new.jpg", binStr)  
  24.   put (the milliseconds-ms) && "ms"
  25. end
  26.  
[raw code]