-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from orhanobut/refactoring
Refactor old tests and remove deprecated codes
- Loading branch information
Showing
30 changed files
with
1,497 additions
and
1,002 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
29 changes: 25 additions & 4 deletions
29
hawk/src/main/java/com/orhanobut/hawk/Base64Encryption.java
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 |
---|---|---|
@@ -1,22 +1,43 @@ | ||
package com.orhanobut.hawk; | ||
|
||
import android.util.Base64; | ||
|
||
/** | ||
* Provides Base64 Algorithm | ||
* Provides Base64 encoding as non-encryption option. | ||
* This doesn't provide any encryption | ||
*/ | ||
public class Base64Encryption implements Encryption { | ||
class Base64Encryption implements Encryption { | ||
@Override public boolean init() { | ||
return true; | ||
} | ||
|
||
@Override public String encrypt(byte[] value) { | ||
return DataHelper.encodeBase64(value); | ||
return encodeBase64(value); | ||
} | ||
|
||
@Override public byte[] decrypt(String value) { | ||
return DataHelper.decodeBase64(value); | ||
return decodeBase64(value); | ||
} | ||
|
||
@Override public boolean reset() { | ||
return true; | ||
} | ||
|
||
String encodeBase64(byte[] bytes) { | ||
try { | ||
return Base64.encodeToString(bytes, Base64.DEFAULT); | ||
} catch (Exception e) { | ||
Logger.w(e.getMessage()); | ||
return null; | ||
} | ||
} | ||
|
||
byte[] decodeBase64(String value) { | ||
try { | ||
return Base64.decode(value, Base64.DEFAULT); | ||
} catch (Exception e) { | ||
Logger.w(e.getMessage()); | ||
return null; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.