Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
marcus.hardt
pluto
Commits
70feadf7
Commit
70feadf7
authored
Oct 14, 2014
by
marcus-tun
Browse files
added a testwise getKey function and removed +/ from the base64 encoding characters
parent
ded377d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/js/blowfish/blowfish.js
View file @
70feadf7
...
...
@@ -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
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment