54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
namespace Common.Hardware.WaterMeter.eRegister.Features
|
|
{
|
|
using System;
|
|
|
|
using Common.Hardware.SIRT;
|
|
|
|
public class ChangeSensusRFEncryptionKey : Pam
|
|
{
|
|
public ChangeSensusRFEncryptionKey()
|
|
: base(17, ChangeSensusRFEncryptionKey)
|
|
{
|
|
}
|
|
|
|
public ChangeSensusRFEncryptionKey(byte[] encryptionKey)
|
|
: this()
|
|
=> this.Key = encryptionKey;
|
|
|
|
public ChangeSensusRFEncryptionKey(string encryptionKey)
|
|
: this()
|
|
=> this.HexKey = encryptionKey;
|
|
|
|
public byte[] Key
|
|
{
|
|
get
|
|
{
|
|
var key = new byte[16];
|
|
|
|
Array.Copy(this.bytes, 1, key, 0, 16);
|
|
|
|
return key;
|
|
}
|
|
set
|
|
{
|
|
if (value?.Length == 16)
|
|
{
|
|
value.CopyTo(this.bytes, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
public string HexKey
|
|
{
|
|
get => BitConverter
|
|
.ToString(this.Key)
|
|
.Replace("-", string.Empty);
|
|
set => this.Key = value.GetEncryptionKey();
|
|
}
|
|
|
|
public static implicit operator ChangeSensusRFEncryptionKey(byte[] value) => new ChangeSensusRFEncryptionKey(value);
|
|
|
|
public static implicit operator ChangeSensusRFEncryptionKey(string value) => new ChangeSensusRFEncryptionKey(value);
|
|
}
|
|
}
|