Skip to content

Commit

Permalink
fix error code.
Browse files Browse the repository at this point in the history
  • Loading branch information
KagayamaKaede committed Nov 23, 2015
1 parent 0ad319d commit c169b01
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.proxy.shadowsocksr.impl.crypto
import com.proxy.shadowsocksr.impl.ImplUtils
import com.proxy.shadowsocksr.impl.crypto.crypto.*
import java.nio.charset.Charset
import java.util.*

object CryptoManager
{
Expand All @@ -14,7 +15,7 @@ object CryptoManager
Pair("chacha20", intArrayOf(32, 8)),
Pair("rc4-md5", intArrayOf(16, 16)))

private val cachedKeys: Map<String, ByteArray> = mapOf()
private val cachedKeys: HashMap<String, ByteArray> = hashMapOf()

fun getMatchCrypto(cryptMethod: String = "chacha20", password: String = "0"): AbsCrypto
{
Expand All @@ -30,7 +31,7 @@ object CryptoManager
val passbf = password.toByteArray(Charset.forName("UTF-8"))
key = ByteArray(cryptMethodInfo[0])
ImplUtils.EVP_BytesToKey(passbf, key)
cachedKeys.plus(Pair(k, key))
cachedKeys.put(k, key)
}
//
if (cryptMethod.startsWith("aes-"))
Expand All @@ -41,9 +42,9 @@ object CryptoManager
when (cryptMethod)
{
"salsa20" -> return SalsaCrypto(cryptMethod, key)
"rc4-md5" -> return RC4MD5Crypto(cryptMethod,key)
"rc4-md5" -> return RC4MD5Crypto(cryptMethod, key)
//...
else -> return ChachaCrypto(cryptMethod, key)//default chacha20
else -> return ChachaCrypto(cryptMethod, key)//default chacha20
}
}

Expand Down

0 comments on commit c169b01

Please sign in to comment.