public byte[] dameResume() { byte[] buffer = new byte[Key.Length + IV.Length]; Key.CopyTo(buffer, 0); IV.CopyTo(buffer, Key.Length); return(buffer); }
public override int TransformFinal(ReadOnlySpan <byte> input, Span <byte> output) { int outputSize = 0; int blockSize = BlockSizeInBytes; if (input.Length >= blockSize) { int alignedLength = input.Length - (input.Length % blockSize); outputSize += Transform(input.Slice(0, alignedLength), output.Slice(0, alignedLength)); input = input.Slice(alignedLength); output = output.Slice(alignedLength); } if (input.Length > 0) { blockTransform.Transform(FR, FRE); // TODO: Vectorize for (int i = 0; i < input.Length; i++) { FRE[i] ^= input[i]; } FRE.AsSpan(0, output.Length).CopyTo(output); outputSize += output.Length; } // Reset vectors IV.CopyTo(FR.AsSpan()); CryptographicOperations.ZeroMemory(FRE); return(outputSize); }
public byte[] EncryptAll(string raw) { byte[] IV; byte[] encrypted = AESEncrypt(out IV, Encoding.ASCII.GetBytes(raw)); byte[] result = new byte[IV.Length + encrypted.Length]; IV.CopyTo(result, 0); encrypted.CopyTo(result, IVLength); return(result); }
public void save(string salida) { FileStream fStream = new FileStream(salida, FileMode.OpenOrCreate); byte[] buffer = new byte[Key.Length + IV.Length]; Key.CopyTo(buffer, 0); IV.CopyTo(buffer, Key.Length); byte[] encryptedData = ProtectedData.Protect(buffer, entropy, DataProtectionScope.CurrentUser); fStream.Write(encryptedData, 0, encryptedData.Length); fStream.Close(); }