System.Net.SecureOnPassword.GetPasswordBytes C# (CSharp) Method

GetPasswordBytes() public method

Gets the buffer of the password.
public GetPasswordBytes ( ) : byte[]
return byte[]
        public byte[] GetPasswordBytes()
        {
            if (_password == null)
                return null;
            var buffer = new byte[_password.Length];
            Array.Copy(_password, buffer, 0);
            return buffer;
        }

Usage Example

Beispiel #1
0
        /// <summary>Sends a Wake On LAN signal (magic packet) to a client.</summary>
        /// <param name="target">Destination <see cref="IPEndPoint"/>.</param>
        /// <param name="macAddress">The MAC address of the designated client.</param>
        /// <param name="password">The SecureOn password of the client.</param>
        /// <exception cref="ArgumentNullException"><paramref name="macAddress"/> is null.</exception>
        /// <exception cref="SocketException">An error occurred when accessing the socket. See Remarks section of <see cref="UdpClient.Send(byte[], int, IPEndPoint)"/> for more information.</exception>
        public static void Send(IPEndPoint target, PhysicalAddress macAddress, SecureOnPassword password)
        {
            if (macAddress == null)
            {
                throw new ArgumentNullException(nameof(macAddress));
            }

            byte[] passwordBuffer = password?.GetPasswordBytes();
            byte[] packet         = GetWolPacket(macAddress.GetAddressBytes(), passwordBuffer);
            SendPacket(target, packet);
        }
All Usage Examples Of System.Net.SecureOnPassword::GetPasswordBytes