-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Blue Montag
committed
Aug 31, 2016
1 parent
2183e0d
commit 59e2c0a
Showing
5 changed files
with
75 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Creation date: 31/08/2016 | ||
* | ||
*/ | ||
package commons.utils; | ||
|
||
import org.apache.commons.codec.binary.Base64; | ||
|
||
import commons.model.ILatinSquare; | ||
|
||
/** | ||
* @author igallego | ||
* | ||
*/ | ||
public class Base64Utils { | ||
|
||
public static String getLSAsBase64String(ILatinSquare ls) throws Exception { | ||
String result = ""; | ||
byte[] byteArr = new byte[65536];//para guardar el LS de 256*256 | ||
char[] charArr = new char[65536];//para guardar el LS de 256*256 | ||
int k = 0; | ||
for (int i=0; i<ls.size(); i++) { | ||
for(int j=0; j<ls.size(); j++) { | ||
//result+=(Character.toString((char)(ls.getValueAt(i, j).intValue())));//this is to return a string | ||
//byte signedByte = (byte)(ls.getValueAt(i, j).intValue()); | ||
//int unsignedByte = signedByte & (0xff); | ||
char c = (char)(ls.getValueAt(i, j).intValue()); | ||
charArr[k] = c; | ||
k++; | ||
} | ||
} | ||
|
||
//lo codifico base64 | ||
byteArr = new String(charArr).getBytes(); | ||
|
||
Base64 base64 = new Base64();//esta clase esta en el Jar common-codec-1.6.jar | ||
result = base64.encodeToString(byteArr); | ||
return result; | ||
} | ||
|
||
public static String getBase64OfString(String str) throws Exception { | ||
byte[] byteArr = str.getBytes(); | ||
Base64 base64 = new Base64();//esta clase esta en el Jar common-codec-1.6.jar | ||
return base64.encodeToString(byteArr); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters