Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ EncryptData()

static int Internal.NativeCrypto.CapiHelper.EncryptData ( SafeKeyHandle hKey,
ReadOnlySpan< byte > input,
Span< byte > output,
bool isFinal )
inlinestaticpackage

Definition at line 961 of file CapiHelper.cs.

962 {
963 VerifyValidHandle(hKey);
964 int pdwDataLen = input.Length;
965 if (!global::Interop.Advapi32.CryptEncrypt(hKey, SafeHashHandle.InvalidHandle, isFinal, 0, null, ref pdwDataLen, pdwDataLen))
966 {
967 throw GetErrorCode().ToCryptographicException();
968 }
969 byte[] array = new byte[pdwDataLen];
970 input.CopyTo(array);
971 int pdwDataLen2 = input.Length;
972 if (!global::Interop.Advapi32.CryptEncrypt(hKey, SafeHashHandle.InvalidHandle, isFinal, 0, array, ref pdwDataLen2, pdwDataLen))
973 {
974 throw GetErrorCode().ToCryptographicException();
975 }
976 int num = (isFinal ? input.Length : pdwDataLen2);
977 array.AsSpan(0, num).CopyTo(output);
978 return num;
979 }
static void VerifyValidHandle(SafeHandleZeroOrMinusOneIsInvalid handle)

References System.array, Internal.NativeCrypto.CapiHelper.GetErrorCode(), System.input, System.Security.Cryptography.SafeHashHandle.InvalidHandle, and Internal.NativeCrypto.CapiHelper.VerifyValidHandle().

Referenced by Internal.Cryptography.BasicSymmetricCipherCsp.Reset(), and Internal.Cryptography.BasicSymmetricCipherCsp.Transform().