内容表

关于

GeCipher256 class provides means to encrypt and decrypt data.

警告
This class only uses a simple and insecure scrambling. Use advanced algorithms like AES if security is really needed.
For encryption using the MAXON API see Stream Conversions Manual .
// This example demonstrates the encryption and decryption of a string.
Char plainText[] = "O brave new world / That has such people in't!" ; const Int32 length = sizeof (plainText); ApplicationOutput ( "Plain Text: @" _s, maxon::String (plainText));

// Define an en-/decryption key. const Char key[32] = { '7' , 'c' , '3' , '0' , 'e' , '0' , '0' , 'b' , 'b' , '6' , '2' , '7' , '1' , '4' , '9' , '5' }; const Int32 keyLength = sizeof (key); // in bytes

// Initialize GeCipher256 instance. GeCipher256 cipher; if (!cipher. Open (key, keyLength, false )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION , "The function exited unexpectedly on initializing GeCipher256" _s);

// Encryption is in-situ. cipher. Encrypt (plainText, length);

// Get a copy of the encrypted string, just for the purpose of displaying it on console. Char plainTextEncoded[ sizeof (plainText) + 1]; // one extra byte for null termination CopyMem (plainText, plainTextEncoded, length); plainTextEncoded[ sizeof (plainText)] = 0; // string null termination

// Note: This is too simple and might only show part of the string, if the encoded string contains null bytes. ApplicationOutput ( "Encoded Text: @" _s, maxon::String (plainTextEncoded));

// Decryption is in-situ. cipher. Decrypt (plainText, length); const maxon::String str { ( char *)plainText }; ApplicationOutput ( "Decoded text: @" _s, str); cipher. 关闭 ();

创建

A GeCipher256 instance can be created by simply defining it (e.g. as a local variable). No special allocation is needed.

使用

Encryption / Decryption

延伸阅读

GeCipher256
A class that encrypts data using an insecure scrambling.
定义: c4d_tools.h:2860
GeCipher256::Encrypt
void Encrypt(void *mem, Int32 size)
maxon::String
定义: string.h:1197
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
GeCipher256::Close
void Close()
Closes the cipher engine.
GeCipher256::Decrypt
void Decrypt(void *mem, Int32 size)
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
GeCipher256::Open
Bool Open(const void *key, Int32 klength, Bool stream)
Char
maxon::Char Char
定义: ge_sys_math.h:54
CopyMem
void CopyMem(const void *s, void *d, Int size)
定义: c4d_memory.h:66

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1