Привет. Вот нашел пакет для шифрования xxtea.
Заюзал. Первый запуск (пример) прошел 15ms.
Потом обновление страницы в браузере и выполнение кода 1ms (если верить FireBug)
Потом подумал что кеш какой то вот и всё. Добавил туда переменную которую передаю из вне. Один фиг время выполнения 1ms - 3ms и это время не зависит от количества текста.
А если долго не трогать этот url то первый заход на него 300ms может быть. А потом пихаю новые данные и обратно 1 - 3 ms
Как вообще работает Go ?
Зарание спасибо за ответ.
библиотека
https://github.com/xxtea/xxtea-go
код
package main
import (
"fmt"
"log"
"microService/libs/httprouter"
"microService/libs/xxtea"
"net/http"
)
func main() {
router := httprouter.New()
router.GET("/:data", xxteaTest)
log.Fatal(http.ListenAndServe(":8081", router))
}
func xxteaTest(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
str := ps.ByName("data")
key := "o_U*&^(234/]|generals|[24432?>?))"
encrypt_data := xxtea.Encrypt([]byte(str), []byte(key))
decrypt_data := string(xxtea.Decrypt(encrypt_data, []byte(key)))
fmt.Fprint(w, encrypt_data)
fmt.Fprint(w, "<br><br><br><br><br><br><br><br>")
fmt.Fprint(w, decrypt_data)
}
запрос
localhost:8081/%D0%9D%D0%B0%D1%87%D0%BD%D1%83%20%D...,%20%D1%87%D1%82%D0%BE%20%D0%BD%D0%B0%20%D1%80%D0%B8%D1%81%D1%83%D0%BD%D0%BA%D0%B5%20%E2%80%94%20%D1%8D%D1%82%D0%BE%20%D0%BC%D0%BE%D0%B5%20%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D0%B5%20%D0%BF%D0%BE%20%D0%BF%D1%80%D0%BE%D0%B8%D0%B7%D0%B2%D0%BE%D0%B4%D0%B8%D1%82%D0%B5%D0%BB%D1%8C%D0%BD%D0%BE%D1%81%D1%82%D0%B8.%20%D0%9A%D0%B0%D0%BA%20%D0%B2%D0%B8%D0%B4%D0%B8%D1%82%D0%B5,%20%D0%B8%D0%B3%D1%80%D0%BE%D0%B2%D0%BE%D0%B5%20%D0%BF%D0%BE%D0%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0%BB%D1%8C%D1%88%D0%B5%20%D0%BD%D0%B5%D0%BE%D0%B6%D0%B8%D0%B4%D0%B0%D0%BD%D0%BD%D0%BE%D1%81%D1%82%D0%B8%20%D0%B2%20%D0%B8%D0%B3%D1%80%D0%BE%D0%B2%D0%BE%D0%B9%20%D0%BF%D1%80%D0%BE%D1%86%D0%B5%D1%81%D1%81.%20%D0%95%D1%81%D0%BB%D0%B8%20%D1%83%D1%87%D0%B5%D1%81%D1%82%D1%8C,%20%D1%87%D1%82%D0%BE%20%D0%BF%D1%80%D0%B8%20.
Первый раз отработал за 17ms потом за 2ms.
Потом отошел на минут 7. Пришел обновил страницу и выполнилось за 300ms. Обновил ещё раз 3ms.