Commit 70feadf7 authored by marcus-tun's avatar marcus-tun
Browse files

added a testwise getKey function and removed +/ from the base64 encoding characters

parent ded377d3
......@@ -33,7 +33,8 @@ crypto.outputTypes = {
var base64 = {};
var p="=";
var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
//var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
base64.encode=function(/* byte[] */ba){
// summary:
......@@ -474,6 +475,31 @@ crypto.Blowfish = new function(){
iv.left=ba[0]*POW24|ba[1]*POW16|ba[2]*POW8|ba[3];
iv.right=ba[4]*POW24|ba[5]*POW16|ba[6]*POW8|ba[7];
};
// Added by marcus
this.getKey=function(key, outputType) {
// summary:
// returns the key in the output format specified by outputType
var k = init(key);
var out=outputType||crypto.outputTypes.Base64;
switch(out){
case crypto.outputTypes.Hex:{
return arrayUtil.map(k, function(item){
return (item<=0xf?'0':'')+item.toString(16);
}).join(""); // hex
}
case crypto.outputTypes.String:{
return k.join(""); // string
}
case crypto.outputTypes.Raw:{
return k; // array
}
default:{
return base64.encode(k.p); // base64 string
}
}
//return base64.encode(k);
}
// End added by marcus
this.encrypt = function(/* string */plaintext, /* string */key, /* object? */ao){
// summary:
......@@ -536,6 +562,8 @@ crypto.Blowfish = new function(){
return cipher; // array
}
default:{
//document.write('returning cipher in base64<br/>\n');
//document.write('cipher: ' + base64.encode(cipher));
return base64.encode(cipher); // string
}
}
......@@ -632,4 +660,4 @@ if (typeof exports != 'undefined') {
global.blowfish = crypto.Blowfish;
}
}(this));
\ No newline at end of file
}(this));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment