附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 2 месеци
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package test
  2. import (
  3. "applet/app/utils"
  4. "encoding/base64"
  5. "fmt"
  6. "testing"
  7. )
  8. func TestAesCrypt_Encrypt(t *testing.T) {
  9. var aesCrypt = utils.AesCrypt{
  10. Key: []byte("e{&[^<wpliI$AgKs:>Ft(.~g]1eR-]VO"),
  11. Iv: []byte("ZV`7<5X]/2brS@sz"),
  12. }
  13. var text = `{"uid":"82","applyOrder":"821607392542143106","db":{"db_host":"119.23.182.117","db_port":"3306","db_name":"fnuoos_template","db_username":"root","db_password":"Fnuo123com@"}}`
  14. result, err := aesCrypt.Encrypt([]byte(text))
  15. if err != nil {
  16. fmt.Println(err)
  17. return
  18. }
  19. pass64 := base64.StdEncoding.EncodeToString(result)
  20. fmt.Println(pass64)
  21. }
  22. func TestAesCrypt_Decrypt(t *testing.T) {
  23. var aesCrypt = utils.AesCrypt{
  24. Key: []byte("e{&[^<wpliI$AgKs:>Ft(.~g]1eR-]VO"),
  25. Iv: []byte("ZV`7<5X]/2brS@sz"),
  26. }
  27. pass64 := "JD0RXX1YbZPWKeNiVKsq0jQ1Bfnbln3fIMcmJkovU5gUCf329y9ZdqECWe4OKpoOk25/hPNaBH9VwellhIQhpw=="
  28. bytesPass, err := base64.StdEncoding.DecodeString(pass64)
  29. if err != nil {
  30. fmt.Println(err)
  31. return
  32. }
  33. plainText, err := aesCrypt.Decrypt(bytesPass)
  34. if err != nil {
  35. fmt.Println(err)
  36. return
  37. }
  38. fmt.Println(string(plainText))
  39. }
  40. func Test_Vi(t *testing.T) {
  41. fmt.Println("123")
  42. fmt.Println([]byte("ZV`7<5X]/2brS@sz"))
  43. }