diff --git a/src/main/java/video/api/uploader/api/work/UploadWorkerHelper.kt b/src/main/java/video/api/uploader/api/work/UploadWorkerHelper.kt index b912330..5cf99f4 100644 --- a/src/main/java/video/api/uploader/api/work/UploadWorkerHelper.kt +++ b/src/main/java/video/api/uploader/api/work/UploadWorkerHelper.kt @@ -8,6 +8,7 @@ import androidx.work.WorkManager import video.api.uploader.api.upload.IProgressiveUploadSession import video.api.uploader.api.work.UploadWorkerHelper.upload import video.api.uploader.api.work.stores.ProgressiveUploadSessionStore +import video.api.uploader.api.work.utils.md5 import video.api.uploader.api.work.workers.ProgressiveUploadWorker import video.api.uploader.api.work.workers.UploadWorker import java.io.File @@ -418,7 +419,7 @@ object UploadWorkerHelper { * @return The tag */ fun getTagForVideoId(videoId: String): String { - return "($PREFIX_VIDEO_ID$videoId)" + return "($PREFIX_VIDEO_ID${videoId.md5()})" } /** @@ -428,7 +429,7 @@ object UploadWorkerHelper { * @return The tag */ fun getTagForUploadToken(token: String): String { - return "($PREFIX_TOKEN$token)" + return "($PREFIX_TOKEN${token.md5()})" } private const val PREFIX_VIDEO_ID = "videoId=" diff --git a/src/main/java/video/api/uploader/api/work/utils/Hash.kt b/src/main/java/video/api/uploader/api/work/utils/Hash.kt new file mode 100644 index 0000000..4443822 --- /dev/null +++ b/src/main/java/video/api/uploader/api/work/utils/Hash.kt @@ -0,0 +1,14 @@ +package video.api.uploader.api.work.utils + +import java.security.MessageDigest + +fun String.md5(): String { + return hashString(this, "MD5") +} + +private fun hashString(input: String, algorithm: String): String { + return MessageDigest + .getInstance(algorithm) + .digest(input.toByteArray()) + .fold("") { str, it -> str + "%02x".format(it) } +} \ No newline at end of file