コード例 #1
0
        public PrivateKey GenerateKeyPair(string description)
        {
            var cu      = new CryptUtility();
            var keyPair = cu.GenerateKeyPair(KeyEmail);

            var publicKeyId = UploadPublicKey(keyPair.PublicKey, description);

            var privateKey = new PrivateKey
            {
                ArmoredKey  = keyPair.PrivateKey,
                PublicKeyID = publicKeyId
            };

            return(privateKey);
        }
コード例 #2
0
        public string GetKeycode(string packageId, PrivateKey privateKey)
        {
            var publicKeyId   = privateKey.PublicKeyID;
            var privateKeyStr = privateKey.ArmoredKey;

            var p = ConnectionStrings.Endpoints["getKeycode"].Clone();

            p.Path = p.Path.Replace("{publicKeyId}", publicKeyId);
            p.Path = p.Path.Replace("{packageId}", packageId);
            var response = _connection.Send <StandardResponse>(p);

            if (response.Response != APIResponse.SUCCESS)
            {
                throw new GettingKeycodeFailedException("Failed to get keycode: " + response.Message);
            }

            var encryptedKeycode = response.Message;

            var cu      = new CryptUtility();
            var keycode = cu.DecryptKeycode(privateKeyStr, encryptedKeycode);

            return(keycode);
        }
コード例 #3
0
        private void DecryptFile(Stream encryptedFile, Stream decryptedFile)
        {
            var cu = new CryptUtility();

            cu.DecryptFile(decryptedFile, encryptedFile, GetDecryptionKey());
        }
コード例 #4
0
        private string CreateChecksum()
        {
            var cu = new CryptUtility();

            return(cu.Pbkdf2(_pkgInfo.KeyCode, _pkgInfo.PackageCode, 1024));
        }