Search Results for

    Show / Hide Table of Contents

    Class Crypter

    Provides methods for encrypting and decrypting strings using a simple XOR-based algorithm.

    Inheritance
    System.Object
    Crypter
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: UniUtils.Data
    Assembly: cs.temp.dll.dll
    Syntax
    public class Crypter

    Methods

    Decrypt(Byte[], String)

    Decrypts a byte array using a XOR-based algorithm and returns the decrypted string.

    Declaration
    public static string Decrypt(byte[] encryptedBytes, string encryptionKey)
    Parameters
    Type Name Description
    System.Byte[] encryptedBytes

    The byte array containing the encrypted data.

    System.String encryptionKey

    The encryption key used for the XOR operation.

    Returns
    Type Description
    System.String

    The decrypted string.

    Examples
    string text = "HelloWorld";
    string key = "k";
    byte[] encrypted = Crypter.Encrypt(text, key);
    string decrypted = Crypter.Decrypt(encrypted, key);
    Debug.Log(decrypted); // "HelloWorld"

    DecryptFromBase64(String, String)

    Decrypts a Base64-encoded string using a XOR-based algorithm and returns the decrypted string.

    Declaration
    public static string DecryptFromBase64(string encryptedBase64, string encryptionKey)
    Parameters
    Type Name Description
    System.String encryptedBase64

    The Base64-encoded string containing the encrypted data.

    System.String encryptionKey

    The encryption key used for the XOR operation.

    Returns
    Type Description
    System.String

    The decrypted string.

    Examples
    string key = "secret";
    string encrypted = Crypter.EncryptToBase64("HiddenMessage", key);
    string decrypted = Crypter.DecryptFromBase64(encrypted, key);
    Debug.Log(decrypted); // Outputs: "HiddenMessage"

    Encrypt(String, String)

    Encrypts a string using a XOR-based algorithm and returns the encrypted data as a byte array.

    Declaration
    public static byte[] Encrypt(string input, string encryptionKey)
    Parameters
    Type Name Description
    System.String input

    The input string to encrypt.

    System.String encryptionKey

    The encryption key used for the XOR operation.

    Returns
    Type Description
    System.Byte[]

    A byte array containing the encrypted data.

    Examples
    string original = "Secret123";
    string key = "key!";
    byte[] encrypted = Crypter.Encrypt(original, key);
    // encrypted contains binary data

    EncryptToBase64(String, String)

    Encrypts a string using a XOR-based algorithm and returns the encrypted data as a Base64-encoded string.

    Declaration
    public static string EncryptToBase64(string input, string encryptionKey)
    Parameters
    Type Name Description
    System.String input

    The input string to encrypt.

    System.String encryptionKey

    The encryption key used for the XOR operation.

    Returns
    Type Description
    System.String

    A Base64-encoded string containing the encrypted data.

    Examples
    string secret = "MyPassword";
    string key = "abc123";
    string encryptedBase64 = Crypter.EncryptToBase64(secret, key);
    Debug.Log(encryptedBase64); // Outputs something like: "GhoaFh1R..."
    In This Article
    Back to top UniUtils Documentation