コード例 #1
0
        /// <summary>
        /// Encrypts the message, using the Sodium cryptography.
        /// </summary>
        internal override void Encrypt()
        {
            KeyPairGL     KeyPair = new KeyPairGL(Keys.Sodium.PublicKey, Keys.Sodium.PrivateKey);
            Blake2BHasher Blake2B = new Blake2BHasher();

            Blake2B.Update(KeyPair.PublicKey);
            Blake2B.Update("7eb15f65bdd576619abbd0b0650c45db1020f5ec969fcf48a828424f1bc8d809".HexaToBytes());

            byte[] Nonce = Blake2B.Finish();

            Crypto CryptoKeys = new Crypto
            {
                PublicKey = "7eb15f65bdd576619abbd0b0650c45db1020f5ec969fcf48a828424f1bc8d809".HexaToBytes()
            };

            CryptoKeys.Sodium = new Sodium(CryptoKeys);

            byte[] Encrypted = CryptoKeys.Sodium.Encrypt(this.Data.ToArray(), Nonce);
            Encrypted = KeyPair.PublicKey.Concat(Encrypted).ToArray();

            this.Data.Clear();
            this.Data.AddRange(Encrypted);

            this.Length = (uint)this.Data.Count;
        }
コード例 #2
0
 /// <summary>
 ///     Initialize a new instance of the <see cref="Keys.Crypto" />
 ///     class.
 /// </summary>
 /// <param name="_PublicKey">
 ///     The <see langword="public" /> key.
 /// </param>
 /// <param name="_PrivateKey">
 ///     The <see langword="private" /> key.
 /// </param>
 public Crypto(byte[] _PublicKey, byte[] _PrivateKey)
 {
     this._KeyPair = Library.Sodium.Sodium.GenerateKeyPair(_PublicKey, _PrivateKey);
 }