refactor: simplify codebase (-209 lines)
This commit is contained in:
@@ -3,7 +3,7 @@ package crypto
|
||||
import (
|
||||
"crypto/cipher"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"encoding/hex"
|
||||
|
||||
"golang.org/x/crypto/blowfish"
|
||||
)
|
||||
@@ -12,7 +12,7 @@ var iv = []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}
|
||||
|
||||
func GetKey(secretKey, songID string) []byte {
|
||||
hash := md5.Sum([]byte(songID))
|
||||
hashHex := fmt.Sprintf("%x", hash)
|
||||
hashHex := hex.EncodeToString(hash[:])
|
||||
|
||||
key := []byte(secretKey)
|
||||
for i := 0; i < len(hash); i++ {
|
||||
@@ -28,9 +28,8 @@ func Decrypt(data, key []byte) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mode := cipher.NewCBCDecrypter(block, iv)
|
||||
decrypted := make([]byte, len(data))
|
||||
mode.CryptBlocks(decrypted, data)
|
||||
cipher.NewCBCDecrypter(block, iv).CryptBlocks(decrypted, data)
|
||||
|
||||
return decrypted, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user