var SixFour = {};
(function(){ var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .';
var encodeChar = function(chr){ var idx = chars.indexOf(chr); if(idx === -1){ // not a sixfour character return null; }
var dna = DNA.encodeUInt(idx); while(dna.length < 3){ // pad to 3 dna = dna + 'A'; }
return dna; };
var decodeChar = function(dna){ var num = DNA.decodeUInt(dna);
if(num < 0 || num > chars.length){ // not in sixfour return null; }
return chars[num]; };
var encodeStr = function(str){ var ret = ; for(var i = 0; i < str.length; i++){ var chr = encodeChar(str[i]); if(chr === null){ return null; } ret += chr; } return ret; };
var decodeStr = function(dna){ var ret = ;
for(var i = 0; i < dna.length; i += 3){ // per 3 base-pairs var chr = decodeChar(dna.substr(i, 3)); if(chr === null){ return null; } ret += chr; }
return ret; };
SixFour = { 'encodeChar': encodeChar, 'decodeChar': decodeChar, 'encodeStr': encodeStr, 'decodeStr': decodeStr }; })();