开发者

Javascript Base64 decode using a reverse loop?

开发者 https://www.devze.com 2023-04-01 22:44 出处:网络
According to this: http://jsperf.com/fors-vs-while/15running loops in reverse in javascript yield much f开发者_如何转开发aster results.Has anyone heard of or tried decoding Base64 strings using javasc

According to this: http://jsperf.com/fors-vs-while/15 running loops in reverse in javascript yield much f开发者_如何转开发aster results. Has anyone heard of or tried decoding Base64 strings using javascript in reverse?


The algorithm would be something like :

   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.
0

精彩评论

暂无评论...
验证码 换一张
取 消