-
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.
added encryption to the storage system
added some more styling fine tuned date parsing added link to my page added versioning reset db location
- Loading branch information
Showing
8 changed files
with
95 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.idea | ||
project/target | ||
target | ||
db.csv | ||
target |
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
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,35 @@ | ||
package com.shiftio.alist.api | ||
|
||
import java.util.Base64 | ||
import javax.crypto.Cipher | ||
import javax.crypto.spec.{IvParameterSpec, SecretKeySpec} | ||
|
||
object Golem { | ||
|
||
private val key = "DSRqGmPgssSfx6r9" | ||
private val initVector = "QFMgtdtxp6QektB4" | ||
|
||
def encrypt(text: String): String = { | ||
|
||
val iv = new IvParameterSpec(initVector.getBytes("UTF-8")) | ||
val keySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES") | ||
|
||
val cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING") | ||
cipher.init(Cipher.ENCRYPT_MODE, keySpec, iv) | ||
|
||
val encrypted = cipher.doFinal(text.getBytes()) | ||
return Base64.getEncoder.encodeToString(encrypted) | ||
} | ||
|
||
def decrypt(text: String): String = { | ||
val iv = new IvParameterSpec(initVector.getBytes("UTF-8")) | ||
val skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES") | ||
|
||
val cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING") | ||
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv) | ||
val original = cipher.doFinal(Base64.getDecoder.decode(text)) | ||
|
||
new String(original) | ||
} | ||
|
||
} |
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