Skip to main content
Version: 2.x

UOdinCrypto

Optional, pluggable encryption module for room communications. A cipher can be attached to an ODIN room handle on creation to enable customizable, end-to-end encryption (E2EE). When enabled, it intercepts data right before transmission and immediately after reception, allowing custom processing of datagrams, messages and custom peer user data. The structure provides a suite of callback functions for initialization, cleanup, event handling and encryption/decryption tasks, along with parameters to adjust for any additional capacity overhead.

Declaration
UCLASS(Blueprintable, ClassGroup = Odin)
class ODIN_API UOdinCrypto : public UObject
  • Header: #include "OdinCryptoExtension.h"
  • Module: Odin
  • Inherits from: UObject
  • Blueprint: Blueprintable · Blueprint reference

Overview​

Functions​

NameDescription
ConstructCrypto
GetPeerStatusReturns the encryption state of a peer: Encrypted if it uses the same secret, Invalid Password if it uses a different one, Unencrypted if it joined without encryption, or Unknown.
GetSecret
SetSecret
MarkAttachedToRoomMarks the native cipher as owned by a room.
IsAttachedToRoomWhether a room has taken ownership of the native cipher.
InvalidateHandleDrops the reference to the native cipher without freeing it (e.g.
GetHandle
SetHandle

Functions​

ConstructCrypto​

Overload 1

Static

static UOdinCrypto* ConstructCrypto(UObject* WorldContextObject, OdinCipher* handle);
ParameterTypeDescription
WorldContextObjectUObject*
handleOdinCipher*

Returns UOdinCrypto*

Overload 2

Static · Blueprint: Construct Crypto Extension

Creates a crypto extension for end-to-end encryption (E2EE) with the given shared secret. Pass it to the Crypto input of Connect Room. All peers in the room need the same secret to understand each other; check a peer with Get Peer Crypto Status.

UFUNCTION(BlueprintCallable, Category = "Odin|Room")
static UOdinCrypto* ConstructCrypto(UObject* WorldContextObject, const TArray<uint8>& Secret);
ParameterTypeDescription
WorldContextObjectUObject*
Secretconst TArray<uint8>&The shared secret, e.g. from Odin String To Bytes. You can change it later with Set Crypto Password on the room.

Returns UOdinCrypto* – The crypto extension.

GetPeerStatus​

Blueprint: Get Peer Crypto Status

Returns the encryption state of a peer: Encrypted if it uses the same secret, Invalid Password if it uses a different one, Unencrypted if it joined without encryption, or Unknown.

UFUNCTION(BlueprintPure, Category = "Odin|Room|Crypto")
EOdinCryptoPeerStatus GetPeerStatus(int64 PeerId);
ParameterTypeDescription
PeerIdint64The remote peer.

Returns EOdinCryptoPeerStatus – The encryption state of the peer.

GetSecret​

Const

UFUNCTION(BlueprintInternalUseOnly, BlueprintPure, Category = "Odin|Room")
TArray<uint8> GetSecret() const;

Returns TArray<uint8>

SetSecret​

UFUNCTION(BlueprintInternalUseOnly, BlueprintCallable, Category = "Odin|Room")
void SetSecret(const TArray<uint8>& NewSecret);
ParameterTypeDescription
NewSecretconst TArray<uint8>&

MarkAttachedToRoom​

Marks the native cipher as owned by a room. The room frees the cipher together with odin_room_free, so this wrapper must not free or re-attach it afterwards.

void MarkAttachedToRoom();

IsAttachedToRoom​

Const

Whether a room has taken ownership of the native cipher.

bool IsAttachedToRoom() const;

Returns bool

InvalidateHandle​

Drops the reference to the native cipher without freeing it (e.g. after the owning room was freed).

void InvalidateHandle();

GetHandle​

Const · Inline

OdinCipher* GetHandle() const;

Returns OdinCipher*

SetHandle​

Inline

void SetHandle(OdinCipher* NewHandle);
ParameterTypeDescription
NewHandleOdinCipher*

Properties​

Secret​

Blueprint: Get/Set

The shared secret of the crypto extension.

UPROPERTY(BlueprintGetter = GetSecret, BlueprintSetter = SetSecret, Category = "Odin|Room")
TArray<uint8> Secret;