使用反向循环的Javascript Base64解码?

时间:2011-09-03 01:31:13

标签: javascript base64

根据这个:http://jsperf.com/fors-vs-while/15在javascript中反向运行循环会产生更快的结果。有没有人听过或尝试使用反向解码Base64字符串?

1 个答案:

答案 0 :(得分:0)

算法类似于:

   1. Pad the input string to a multiple of 3 characters
   2. Initialize an empty results array 
   3. Looping backwards in the input string taking 3 chars at a time
   4.    convert 3 chars to the 4 Base64 equivalent
   5.    unshift the Base64 string to the results array
   6. Return the join of the results array.