|
| 1 | +package phpfuncs |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/serkanalgur/phpfuncs" |
| 7 | +) |
| 8 | + |
| 9 | +func CoverCheck(t *testing.T, s, exp string) { |
| 10 | + if s != exp { |
| 11 | + t.Errorf("%q (expected: %q)", s, exp) |
| 12 | + } |
| 13 | +} |
| 14 | + |
| 15 | +// HashCheckSha1 - Test for Encryption |
| 16 | +func HashCheckSha1(t *testing.T) { |
| 17 | + want := "0a4d55a8d778e5022fab701977c5d840bbc486d0" |
| 18 | + CoverCheck(t, phpfuncs.Hash("sha1", "Hello World"), want) |
| 19 | +} |
| 20 | + |
| 21 | +// HashCheckSha224 - Test for Encryption |
| 22 | +func HashCheckSha224(t *testing.T) { |
| 23 | + want := "c4890faffdb0105d991a461e668e276685401b02eab1ef4372795047" |
| 24 | + CoverCheck(t, phpfuncs.Hash("sha224", "Hello World"), want) |
| 25 | +} |
| 26 | + |
| 27 | +// HashCheckSha256 - Test for Encryption |
| 28 | +func HashCheckSha256(t *testing.T) { |
| 29 | + want := "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e" |
| 30 | + CoverCheck(t, phpfuncs.Hash("sha256", "Hello World"), want) |
| 31 | +} |
| 32 | + |
| 33 | +// HashCheckSha384 - Test for Encryption |
| 34 | +func HashCheckSha384(t *testing.T) { |
| 35 | + want := "99514329186b2f6ae4a1329e7ee6c610a729636335174ac6b740f9028396fcc803d0e93863a7c3d90f86beee782f4f3f" |
| 36 | + CoverCheck(t, phpfuncs.Hash("sha384", "Hello World"), want) |
| 37 | +} |
| 38 | + |
| 39 | +// HashCheckSha512 - Test for Encryption |
| 40 | +func HashCheckSha512(t *testing.T) { |
| 41 | + want := "2c74fd17edafd80e8447b0d46741ee243b7eb74dd2149a0ab1b9246fb30382f27e853d8585719e0e67cbda0daa8f51671064615d645ae27acb15bfb1447f459b" |
| 42 | + CoverCheck(t, phpfuncs.Hash("sha512", "Hello World"), want) |
| 43 | +} |
| 44 | + |
| 45 | +// HashCheckSha512 - Test for Encryption (Expecting to return MD5 Hash) |
| 46 | +func HashCheckShaMD5NDefault(t *testing.T) { |
| 47 | + want := "b10a8db164e0754105b7a99be72e3fe5" |
| 48 | + CoverCheck(t, phpfuncs.Hash("sha12525", "Hello World"), want) |
| 49 | +} |
0 commit comments