diff --git a/api.js b/api.js index d18fb94..53c1058 100644 --- a/api.js +++ b/api.js @@ -136,10 +136,10 @@ var cryptico = (function() { // Converts a string to a byte array. my.string2bytes = function(string) { - var bytes = new Array(); + var bytes = new Array(string.length); for(var i = 0; i < string.length; i++) { - bytes.push(string.charCodeAt(i)); + bytes[i] = string.charCodeAt(i); } return bytes; } diff --git a/cryptico.js b/cryptico.js index d7b1d98..47e46e9 100644 --- a/cryptico.js +++ b/cryptico.js @@ -3316,10 +3316,10 @@ var cryptico = (function() { // Converts a string to a byte array. my.string2bytes = function(string) { - var bytes = new Array(); + var bytes = new Array(string.length); for(var i = 0; i < string.length; i++) { - bytes.push(string.charCodeAt(i)); + bytes[i] = string.charCodeAt(i); } return bytes; } diff --git a/cryptico.min.js b/cryptico.min.js index 1373750..230a143 100644 --- a/cryptico.min.js +++ b/cryptico.min.js @@ -99,8 +99,8 @@ a.MixColumns=function(b){for(var c=0;c<16;c+=4){var d=b[c+0],e=b[c+1],g=b[c+2],h a.b256to64=function(a){var c,d,e,g="",h=0,f=0,o=a.length;for(e=0;e>2&63),c=(d&3)<<4):f==1?(g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c|d>>4&15),c=(d&15)<<2):f==2&&(g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c|d>>6&3),h+=1,g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d&63)),h+=1,f+=1,f==3&& (f=0);f>0&&(g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c),g+="=");f==1&&(g+="=");return g};a.b64to256=function(a){var c,d,e="",g=0,h=0,f=a.length;for(d=0;d=0&&(g&&(e+=String.fromCharCode(h|c>>6-g&255)),g=g+2&7,h=c<> 6)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d&63);c+1==a.length?(d=parseInt(a.substring(c,c+1),16),e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d<<2)):c+2==a.length&&(d=parseInt(a.substring(c,c+2),16),e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d>>2)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt((d&3)<<4));for(;(e.length&3)>0;)e+="=";return e};a.b64to16=function(a){var c="", -d,e=0,g;for(d=0;d>2),g=v&3,e=1):e==1?(c+=int2char(g<<2|v>>4),g=v&15,e=2):e==2?(c+=int2char(g),c+=int2char(v>>2),g=v&3,e=3):(c+=int2char(g<<2|v>>4),c+=int2char(v&15),e=0))}e==1&&(c+=int2char(g<<2));return c};a.string2bytes=function(a){for(var c=[],d=0;d>2),g=v&3,e=1):e==1?(c+=int2char(g<<2|v>>4),g=v&15,e=2):e==2?(c+=int2char(g),c+=int2char(v>>2),g=v&3,e=3):(c+=int2char(g<<2|v>>4),c+=int2char(v&15),e=0))}e==1&&(c+=int2char(g<<2));return c};a.string2bytes=function(a){for(var c=Array(a.length),d=0;d