public String encryption(String string, boolean decrypt,
                                         SecurityManager securityManager) {
        // get the security manager instance
        if (securityManager != null && reference != null) {
            // get the key
            byte[] key = securityManager.getDecryptionKey();

            // convert string to bytes.
            byte[] textBytes =
                Utils.convertByteCharSequenceToByteArray(string);

            // Decrypt String
            if (decrypt){
                textBytes = securityManager.decrypt(reference,
                    key,
                    textBytes);
            }else{
                textBytes = securityManager.encrypt(reference,
                    key,
                    textBytes);
            }

            // convert back to a string
            return Utils.convertByteArrayToByteString(textBytes);
        }
        return string;
    }