47 lines
974 B
Go
47 lines
974 B
Go
package cryptojs
|
|
|
|
import "testing"
|
|
|
|
func Test_EncryptDecrypt(t *testing.T) {
|
|
enc, err := Encrypt("testing123", "testing")
|
|
|
|
if err != nil {
|
|
t.Fatal("Unable to encrypt:", err)
|
|
}
|
|
|
|
b, err := Decrypt(enc, "testing")
|
|
|
|
if err != nil {
|
|
t.Fatal("Unable to decrypt:", err)
|
|
}
|
|
|
|
final := string(b)
|
|
|
|
if final != "testing123" {
|
|
t.Fatal("Final text does not match:", final)
|
|
}
|
|
}
|
|
|
|
func Test_WebsiteEncrypt(t *testing.T) {
|
|
enc, err := Encrypt("Testing Paste.ee", "wXBbztgFOsZtTvhK1vcZlR7izK84bmUW")
|
|
|
|
if err != nil {
|
|
t.Fatal("Error:", err)
|
|
}
|
|
|
|
if enc != "U2FsdGVkX183sL2jzqJiJdhIl0O7R9v46TIkKnORreGpUufYUsqjqYO9b++CSyvV" {
|
|
t.Fatal("Unexpected output:", enc)
|
|
}
|
|
}
|
|
|
|
func Test_WebsiteDecrypt(t *testing.T) {
|
|
b, err := Decrypt("U2FsdGVkX183sL2jzqJiJdhIl0O7R9v46TIkKnORreGpUufYUsqjqYO9b++CSyvV", "wXBbztgFOsZtTvhK1vcZlR7izK84bmUW")
|
|
|
|
if err != nil {
|
|
t.Fatal("Unable to decrypt:", err)
|
|
}
|
|
|
|
if string(b) != "Testing Paste.ee" {
|
|
t.Fatal("Unexpected output:", string(b))
|
|
}
|
|
} |