-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove salt and sync perl and golang encrypt/decrypt
- Loading branch information
1 parent
a3233df
commit 822f8a8
Showing
3 changed files
with
56 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package pfcrypt | ||
|
||
import ( | ||
"bytes" | ||
"os/exec" | ||
"testing" | ||
) | ||
|
||
func TestRoundTrip(t *testing.T) { | ||
|
||
input := []byte("Hello Test") | ||
ciphertext, err := PfEncrypt(input) | ||
if err != nil { | ||
t.Fatalf("PfEncrypt: %s", err.Error()) | ||
} | ||
|
||
output, err := PfDecrypt(ciphertext) | ||
if err != nil { | ||
t.Fatalf("PfDecrypt: %s", err.Error()) | ||
} | ||
|
||
if bytes.Compare(input, output) != 0 { | ||
t.Fatalf("Input does not match Output") | ||
} | ||
|
||
} | ||
|
||
func TestPerl(t *testing.T) { | ||
expected := []byte("Hello Test") | ||
cmd := exec.Command("perl", "-I/usr/local/pf/lib", "-I/usr/local/pf/lib_perl/lib/perl5", "-Mpf::config::crypt", "-eprint pf::config::crypt::pf_encrypt('Hello Test')") | ||
ciphertext, err := cmd.Output() | ||
if err != nil { | ||
t.Fatalf("perl crypt: %s", err.Error()) | ||
} | ||
|
||
output, err := PfDecrypt(string(ciphertext)) | ||
if err != nil { | ||
t.Fatalf("PfDecrypt: %s", err.Error()) | ||
} | ||
|
||
if bytes.Compare(expected, output) != 0 { | ||
t.Fatalf("expected does not match Output") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters