github.com/viant/toolbox@v0.34.5/cred/blowfish_test.go (about) 1 package cred_test 2 3 import ( 4 "github.com/stretchr/testify/assert" 5 "github.com/viant/toolbox/cred" 6 "testing" 7 ) 8 9 func TestNewBlowfishCipher(t *testing.T) { 10 cipher, err := cred.NewBlowfishCipher(cred.DefaultKey) 11 if assert.Nil(t, err) { 12 13 { 14 var secret = "This is secret pass12312312321" 15 encrypted := cipher.Encrypt([]byte(secret)) 16 decrypted := cipher.Decrypt(encrypted) 17 assert.Equal(t, secret, string(decrypted)) 18 } 19 20 { 21 var secret = "abc" 22 encrypted := cipher.Encrypt([]byte(secret)) 23 decrypted := cipher.Decrypt(encrypted) 24 assert.Equal(t, secret, string(decrypted)) 25 } 26 27 { 28 var secret = "123!abc" 29 encrypted := cipher.Encrypt([]byte(secret)) 30 decrypted := cipher.Decrypt(encrypted) 31 assert.Equal(t, secret, string(decrypted)) 32 } 33 34 { 35 var secret = "test123@423 #!424" 36 encrypted := cipher.Encrypt([]byte(secret)) 37 decrypted := cipher.Decrypt(encrypted) 38 assert.Equal(t, secret, string(decrypted)) 39 } 40 41 { 42 var secret = "test123@423 #!424" 43 encrypted := cipher.Encrypt([]byte(secret)) 44 decrypted := cipher.Decrypt(encrypted) 45 assert.Equal(t, secret, string(decrypted)) 46 } 47 48 } 49 }